Link to home
Start Free TrialLog in
Avatar of ProfessionalDataSystems

asked on

Robocopy rename file

I am copying scanned pdf's from paperport to a mapped drive. The naming for the pdf's are set in paperport as "date(1-X)" for every stack of scanned documents. If I scan in 20 documents in the morning then they will be named date(1-20). They are then transferred to a mapped drive on our network. If I again scan 20 different documents later in the same day then the names of those files will be the same as the documents I scanned in the morning, at which time the files from the morning will be overwritten. I need some means of renaming the files so that they are not overwritten. Below is the script that I am using. I am not an expert with scripts. Any help would be greatly appreciated.

COPY "C:\Users\XXXXXXXX\Documents\My PaperPort Documents\*.*" "C:\Transfer Backup"
Robocopy "C:\Users\XXXXXXXX\My Documents\My PaperPort Documents" Z:\ /MOV /S /r:3 /w:3 /log+:"C:\Transfer Logs\Transferlog.txt"
Avatar of Bill Prew
Bill Prew

It sounds like you have a need to copy files that will have the same name as earlier copied files, and not overwrite them.  Based on that I think you have two basic approaches.

(1) You could create a new folder in the backup destination location before each copy, and then copy the new files into it.

(2) You can rename each file to be copied adding in a date and time stamp to the sequence number, to make sure it is a unique file name, and then move that to the single backup folder.

Do you have a preference?

Avatar of ProfessionalDataSystems


Needs to be in a single folder with unique file names. Currently have a desktop icon to run the script. If that can be modified then that would be perfect.
You can do it with a simple 2-line batch file, as follows:

rename C:\Users\XXXXXXXX\Documents\My PaperPort Documents\*.* *.01.*
copy C:\Users\XXXXXXXX\Documents\My PaperPort Documents\*.* Z:\network-folder

The "01" in the rename command is the scan number that day. First time, it's 01; next time, it's 02; then 03; etc. For example, assuming PDF files, the first batch of the day will have names like "date(1-X).01.PDF" and the second batch will have names like "date(1-X).02.PDF". Or, instead of 01, 02, 03, etc., you could use the time of day (hhmm), such as:

rename C:\Users\XXXXXXXX\Documents\My PaperPort Documents\*.* *.1016.*

for a scan occurring at 10:16am, or:

rename C:\Users\XXXXXXXX\Documents\My PaperPort Documents\*.* *.1622.*

for a scan occurring at 4:22pm. Regards, Joe
I should point out that the copy command will leave the files in the PaperPort docs folder. If you want to have them deleted from the PaperPort folder, then change the copy command to a move command, as follows:

move C:\Users\XXXXXXXX\Documents\My PaperPort Documents\*.* Z:\network-folder

Regards, Joe
Btw, since you're a PaperPort user, you may want to take a look at a PaperPort wiki that I've been involved with:

We have a good relationship with Nuance's Product Manager for PaperPort, and I'll pass along the idea that the PaperPort Scanning Profiles should offer time stamp options along with the date stamp options. As I'm sure you know, PP14 (the latest release) offers many date options (I counted 15 different date formats!) for the item name, prefix, and suffix fields (in the Settings for Scanning Profiles) - but not a single time option! I'm thinking they could offer at least two:

where hh is 00-23. If they want to get fancy, they could also offer a 1-12 hh with an AM/PM indicator. With some luck, maybe they'll put this in the next release, PP15. Regards, Joe
This adds a 01 to the end of every file. What I am looking for is that it be sequential. So the 20 morning scans will be 1-20 at the end and the afternoon will be 21-40. Otherwise, the morning scans will still have the same name as the afternoon ones, all with 01 at the end, and be overwritten. Thanks
OK, I didn't realize you want the file names to be sequential. It seems that you know how to use the settings in PaperPort's Scanning Profiles to set the item name, prefix, and suffix such that you get the date and a sequential number. Why don't you simply scan directly into the network folder? That will keep the sequential numbering intact (I assume you're using one of the nnnnn type options in the suffix field). Btw, what version of PP do you have?
Any thoughts on my previous comment? I'm pretty sure that your problem will be solved via direct scanning to the network folder with PaperPort using appropriate settings in the Scanning Profile, but I'd like to hear your thoughts on it. Regards, Joe
Avatar of ProfessionalDataSystems

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for the delay. What I ended up doing was setting up a scheduled task that ran the batch daily, every AM. This allowed the transfer to only happen once a day and therefore the naming would be sequential. Thanks for all of the suggestions.
OK, thanks for posting what you did. That achieves the same thing with respect to sequential numbering as scanning directly to the network folder. Regards, Joe