Robocopy rename file

ProfessionalDataSystems
ProfessionalDataSystems used Ask the Experts™
on
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"
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
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?

~bp
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.
Joe WinogradDeveloper
Fellow 2017
Most Valuable Expert 2018

Commented:
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
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Joe WinogradDeveloper
Fellow 2017
Most Valuable Expert 2018

Commented:
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
Joe WinogradDeveloper
Fellow 2017
Most Valuable Expert 2018

Commented:
Btw, since you're a PaperPort user, you may want to take a look at a PaperPort wiki that I've been involved with:
http://sites.google.com/site/wikipaperport/

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:

hh.mm
hh.mm.ss

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
Joe WinogradDeveloper
Fellow 2017
Most Valuable Expert 2018

Commented:
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?
Joe WinogradDeveloper
Fellow 2017
Most Valuable Expert 2018

Commented:
ProfessionalDataSystems,
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
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.
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.
Joe WinogradDeveloper
Fellow 2017
Most Valuable Expert 2018

Commented:
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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial