Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to write a batch file to change the names of some files and I am having trouble.
The problem is, there are multiple files that all start with 'AB' followed by 3 random digits. Eg. AB234 and AB453I would like to replace AB with a 4-digit date (0514 for today). So the result would be 0514234 and 0514453.
Using "ren AB* 0514*" results in 05144 and 05143. It appears to keep the file name the same length.
How do I create a longer name without having to know the last 3 digits?
I appreciate any help.

there's a program for this job: file renamer ultra 2000. you can find a shareware version on www.techalchemy.net

That program does just what I need it to. However, I am trying to change the file names with a batch file that is written and executed from Access with a VBA front-end so everyone on my network can use it to download and rename monthly reports for different clients. If I could run File Renamer Ultra 2000 with my arguments from the command line, it would be perfect.
Any suggestions? Let me know if I can give any more information which might be helpful.
Thanks.

Instead of the prefix AB (length=2), you want a 4-digit date (length=4). To get around the file length problem, do this (from inside a batch file):
for %%? in (*) do ren %%? --%%?
That will include a 2 char prefix ("--") to the files. Now, we want to replace --AB for the 4-digit date, which have the same length.
In order to get the date into a variable without the separators (as you want), see my faq:
http://www.batch.hpg.com.br/index.htm#02
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

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