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?