Print this page | Go back to previous topic
Forum nameThe Computer Forum
Topic subjectBatch file to copy and rename files
Topic URLhttp://www.pcqanda.com/dc/dcboard.php?az=show_topic&forum=2&topic_id=566863
566863, Batch file to copy and rename files
Posted by harry, Thu Feb-25-21 04:43 AM
I regularly need to copy and rename files whose filenames have various lengths but always end in the same three characters, which I need to change to another three characters.

For example, if the source files have the names "ABC123BananaAB1.txt" and "DEF345PineappleAB1.docx", then I need to copy them to target files with the names "ABC123BananaXYZ.txt" and "DEF345PineappleXYZ.docx" respectively. In other words, I need the target filenames to be the same as the source filenames but with the last three characters changed from "AB1" to "XYZ".

I tried using a bat file containing the command "copy *AB1.* *XYZ.*", but it didn't work properly. How can I get this to work?
566864, RE: Batch file to copy and rename files
Posted by Paul D, Thu Feb-25-21 03:15 PM
Bulk Rename Utility will do that for you, and much more besides. I've used it for years, and it's absolutely free. I'm assuming the files to be changed are in the same folder, as the software's major limitation is that it can only work in one folder at a time.

https://www.bulkrenameutility.co.uk




Paul D
566866, RE: Batch file to copy and rename files
Posted by Pcqandaman, Thu Feb-25-21 06:25 PM
QUOTE:
Bulk Rename Utility will do that for you, and much more besides. I've used it for years, and it's absolutely free. I'm assuming the files to be changed are in the same folder, as the software's major limitation is that it can only work in one folder at a time.

https://www.bulkrenameutility.co.uk




Paul D

Thanks for this.
I always like it when there is a portable version.
BTW in the current version you can specify sub-directories so with a bit of moving folders around you could scan more than one folder's files.
566865, RE: Batch file to copy and rename files
Posted by therube, Thu Feb-25-21 03:50 PM
And, if you're looking for a command-line program, Bulk Rename Utility :-) has a program, Bulk Rename Command, https://www.bulkrenameutility.co.uk/Download.php, that I would think could do it.


Quote:

C:\TMP\BRU>brc.exe /replaceci:ab1:XYZ


Processing Folder C:\TMP\BRU\

Filename Concerto in D Minor (RV 454) for Oboe, Strings, and Harpsichord - I. Allegro requires no changes

Filename ABC123BananaAB1.txt would be renamed to ABC123BananaXYZ.txt
566870, RE: Batch file to copy and rename files
Posted by harry, Mon Mar-01-21 02:31 AM
Thanks for your replies. It appears that the Batch Rename Command utility will do part of what I need, but it appears that I still need an additional command to make a copy, because I want to end up with the original file AND a renamed copy.

Example:

1. Start with one file ("ABC123BananaAB1.txt").
2. Run batch file to copy/rename.
3. End up with two files ("ABC123BananaAB1.txt" AND "ABC123BananaXYZ.txt").
566894, RE: Batch file to copy and rename files
Posted by Paul D, Fri Mar-12-21 03:59 PM
Open relevant folder
Select files to copy/rename.
Ctrl~C
Ctrl~V (in the same folder)
You will then have your original and copy files, named FilenameABC.aaa and FilenameABC- Copy.aaa respectively.
Using BRU, rename all the "- Copy" files as required.




Paul D
566906, RE: Batch file to copy and rename files
Posted by harry, Mon Mar-15-21 10:59 PM
Thanks for your reply. A batch file containing the following command does the renaming OK, after using Ctrl+C & Ctrl+V to copy and paste the source file manually.

brc64.exe /execute /replaceci:"AB1 - Copy":XYZ

Is it possible to include a command in the batch file to do automatically what Ctrl+C & Ctrl+V does manually; i.e., to copy *AB1.* to *AB1 - Copy.*?