Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Who's an expert with dos?  (Read 4218 times)

0 Members and 1 Guest are viewing this topic.

gilbert

  • Guest
Who's an expert with dos?
« on: August 26, 2004, 06:46:19 AM »
Hi there,

I need to rename a downloaded file using a batch file every day but the file needs to be renamed to match the date of the day.ie, to change from 250804 to 260804.

Any ideas?

Thanks ??? ???

yeah right

  • Guest
Re: Who's an expert with dos?
« Reply #1 on: August 26, 2004, 09:53:14 AM »
this should get the job done for you.... i recommend you create a folder and call it "rename"

in your "rename" folder make a batch file called "step1.bat"  and copy these lines in there:

"
FOR /F "tokens=1-5 delims=/: " %%J IN ('DATE/T') DO SET MMDD=%%K%%L%%M
SET correctdate=%MMDD%
echo %correctdate%

"

then create another batch file called "step2.bat" and put these lines in there

"
CALL step1.bat
FOR %%V IN (*.txt)  DO Rename "%%V" test%correctdate%.txt

"

then create a test file called "date1.txt"

now everytime "step2.bat" is run, it renames all ".txt" files in your "rename" folder with "test08262004.txt" or whatever the date is.  If you want to change a file with a different extension, replace the "*.txt" in the FOR statement of "step2.bat" with whatever extension your file is.  If you want the file to be renamed something else other than "test08262004", replace "test" in "step2.bat" with whatever you want the file to be renamed......

i'm assuming you already have the ftp script to automatically download the file, just make sure that the file is downloaded to the "rename" directory.  To run "step2.bat" automatically, you can you the "AT" command or an easier way to do it would be to use windows task scheduler.....