Batch that copies and renames files... help!

June 17, 2010 at 10:27:16
Specs: Windows XP
Hi, guys! I'm a complete n00b when it comes to batch files, so please bear with me.

I need to create a batch file that copies files with an extension .1 to a particular folder, but that's not all, it has to add a 0 to the filename (removing the first character of the filename) and remove the last character, while keeping the file extension.

Something like this


Should end up like this:


I was able to copy files and add a 0 to the filename (so far I tried this: "xcopy <filename> <destination directory>0*"), but I don't know how to remove the last character of the filename :/

Any help would be greatly appreciated!!

See More: Batch that copies and renames files... help!

Report •

June 17, 2010 at 11:33:07
If the file name is exactly the same length then you could do....

xcopy c:\myfirtstdir\*.* c:\mysecinddir\0?????.1

Use the question marks as wild cards that represent the characters. Note I left the last ? off to delete the last character and used a 0 for the first one.

Report •

June 17, 2010 at 13:05:51
That worked pretty well, ace_omega! Just what I needed, thanks!!!

BTW, what if I have to do the same thing, but the filename is shorter? Where I'm trying this out, the filename is 13 characters long, but they can be shorter than that... any suggestions?

Thanks a LOT!! I really appreciate it! :)

Report •

Related Solutions

Ask Question