Windows 7 Pro

I want to copy a series of files, all named "cover" from different directories to a single directory, and give them all new names. I need help with either of the below options:

Option 1 Use a batch file to copy the source files to a single directory as "cover1", "cover2", etc., then rename by hand.

I can use the below one-line batch file, but it copies files sequentially to the name "cover" in the directory "A", resulting in just one final file.

for /f "delims=" %%L in (Coverscopy.txt) do copy "%%L" A

I presume I should use a loop to add a number to the filename, but I'm afraid I don't seem to know how to vary the file name with each cycle.

Second option Use a batch filed that draws from a CSV file with columns for the original file address and the desired new name.

Unfortunately, I have no idea where to start with this.

Any assistance appreciated.


Use this to copy from one dir to another only files corresponding to a given mask. It's not written for use of multiple source dirs but it can be helpfull.

@echo off
set p="C:\temp"
SET filemask=%p%\*cover*.txt
SET destfolder="C:\temp2"
FOR /F "delims=" %%a IN ('dir /od /a-d /b %filemask%') DO COPY "%p%\%%a" "%destfolder%"
echo Done!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.