Tech Support Forum banner

Batch File

825 Views 6 Replies 3 Participants Last post by  TheOutcaste
Hello

I am using this For Loop to rename a group of files from

ShippingConfirmation_20100702_114533.txt

This has to become

Completed.20100702_114533.txt

How would I make that change?


@ECHO OFF
REM Create a list of files want to rename, and store them in a file
dir shippingconfirmation_*.* /b > filelist.inf

REM Loop through the file, and rename
for /F "tokens=1,2 delims=_" %%A IN (filelist.inf) do rename %%A_%%B Completed.%%B

REM Delete file that contained files to be renamed.
del filelist.inf

Thanks
See less See more
Status
Not open for further replies.
1 - 7 of 7 Posts
Maybe try:
ShippingConfirmation*.* > Completed*.*

but I'm not sure since it might not understand the wildcards.
That won't work.

it produces Completedonfirmation........
You tried? And it just added to it? Well CompletedShippingConfirmation sounds sane to me. It still has completed infront. You could make it Completed_
Our systems produces ShippingConfirmation_20100702_114533.txt

This has to become

Our client has requested this Completed.20100702_114533.txt


What is the best way to do this?
maybe find a way for it to recognize the number at the end as a variable like %number% so it would be Confirmation*.* > Completed.%number%.txt
Code:
For /F "Tokens=1* Delims=_" %%I In ('Dir /B ShippingConfirmation*.txt') Do Rename "%%I_%%J" "Completed.%%J"
1 - 7 of 7 Posts
Status
Not open for further replies.
Top