Computing.Net > Forums > Disk Operating System > Renaming files keeping part of name

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Renaming files keeping part of name

Reply to Message Icon

Name: Greg
Date: May 14, 2002 at 09:28:02 Pacific
Comment:


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 AB453

I 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.



Sponsored Link
Ads by Google

Response Number 1
Name: 386guru
Date: May 14, 2002 at 10:05:08 Pacific
Reply:

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


0

Response Number 2
Name: Greg
Date: May 14, 2002 at 11:18:50 Pacific
Reply:

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.


0

Response Number 3
Name: Secret_Doom
Date: May 14, 2002 at 12:13:06 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Renaming files keeping part of name

rename file w/part of original file www.computing.net/answers/dos/rename-file-wpart-of-original-file/13775.html

Reading text from a file www.computing.net/answers/dos/reading-text-from-a-file/9080.html

rename files www.computing.net/answers/dos/rename-files/14038.html