1.

Solve : Append to DOS File Name?

Answer»

Is there a way to append portions of an existing DOS file name to a new DOS file name? For example, the original file name is RHD_GOK_0001_YP.pdf. I would like to CREATE a new DOS file name called 012345_00009_YP_000_00001.pdf, where the BOLDED YP and 00001 were from the original file name.

I would like to run this in batch as I have thousands of files that need to be renamed on an on-going basis.

Any help would be appreciated. :-?You can use FOR /F with a DIR to break apart a filename if there is going to be a common delimeter like the UNDERSCORE (_) character. If you can give more information, I'd be glad to help you with a batch file. For example:
Do the file names always have the same delimeters?
Do the file names always have the same number of parts?
How do you decide what to rename them to?Thanks for the ASSISTANCE!

The beginning file name will always have the same delimiters however, what will change is the GOK_0001_YP will change to some other combination but their length will always be 3(GOK), 4(0001) and 2(YP) respectively. For example, the next time the file name may be ATK_0099_WP, etc. The file names (old and new) will always have the same number of parts. The new beginning file name (012345_0009) and the _000 shown after the _YP is a product number which will always be the same SIZE and appended to the same location as shown in my original question. The new product number changes every month.

The GOK_0001_YP is how we get the product in, the 012345_0009 is how we ship the product out.Okay, I think I understand.
We have existing file names that are in the format of
aaa_bbbb_cc
and we want to rename them to
012345_00009_cc_bbbb
or do we want to pad the last set with a 0 like
012345_00009_cc_0bbbb
??

Let me know and I'll put together a quick batch file for you.



Discussion

No Comment Found