Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need help writing a batch file that will copy folders and files from one directory to another directory and rename the files. I am scanning files into Dir1 in several different folders that i create when i scan, and after the files are scanned i want to run a batch file that will copy the folders and files into Dir2 and change the filename to it's foldername+a unique number. For instance, the batch file would copy and rename the files:
Dir1\999999999\Page 1.max
Dir1\999999999\Copy of Page 1.max
Dir1\888888888\Page 1.max
Dir1\888888888\Copy of Page 1.max
Dir1\888888888\Copy(2) of Page 1.maxto
Dir2\999999999\999999999_1.max
Dir2\999999999\999999999_2.max
Dir2\888888888\888888888_1.max
Dir2\888888888\888888888_2.max
Dir2\888888888\888888888_3.maxOnce the folders and files are copied and renamed, the folders/files on Dir1 will be deleted, either by a prompt within this batch file or a different batch file. It doesn't really matter. Usually the folders (999999999, etc) will be unique and not on Dir2 when this batch file is run, but occasionally a folder will already be present on Dir2. If that is the case, it would be great if the files could be copied into the folder without overwriting any existing files. For instance, if 888888888\Page 1.max was copied over to Dir2, it would have the name 888888888\888888888_4.max if there was already a _1, _2, and _3.
I hope this is possible, but i don't have enough experience with batch files to know if you can name a file it's foldername and/or have consecutive numbering of files in a folder without overwriting. Any feedback on this would be great.
Thanks alot.
Ben

This is not a STANDALONE DOS FORUM question as per warnings that the forum is not for the COMMAND PROMPT in WINDOWS.

Might be worth Googling around to see if there is a DOS/Batch file forum somewhere. Many of us dabble with batch files but this one looks like the province of an expert.
In the meantime keep an eye on here just in case the right person comes along.
Derek.W

Believe me, i have been googling for quite a while on this and not found anything that will work for me. And this site seemed to be the most likely to catch the eye of someone who could answer my question.
I tried to post this in the DOS forum since that is where most of the batch questions have been addressed, but it was removed. I guess it would probably be best to post it in the programming forum if i want to catch the eye of someone most capable to answer my question.
Is it possible to have a moderator move this post to the Programming forum? I would hate to repost the same message as that is not only rude, but possibly against forum regulations.
Thanks for the suggestions.

![]() |
Laptop not booting into w...
|
Dell Laptop no audio
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |