Help! I’m have been trying to figure a way to write a batch file that will automatically rename a specific file by the date and time.
example: skidog.txt ==> jan191230.txt
The below will rename a file in dirtest
to todays date. Just change the path.
IF NOT “%1″==”date” ECHO Program will rename ECHO a filewith todays date.
IF “%3″==”Mon” SET Day=Monday
IF “%3″==”Tue” SET Day=Tuesday
IF “%3″==”Wed” SET Day=Wednesday
IF “%3″==”Thu” SET Day=Thursday
IF “%3″==”Fri” SET Day=Friday
IF “%3″==”Sat” SET Day=Saturday
IF “%3″==”Sun” SET Day=Sunday
echo rename test*.* %fulldate%.* > try.bat
rem del try.bat
echo A file called %fulldate% has been ECHO created.
Requires the ability to use the DOS extensions (NT4 SP3 or SP4 onwards I think???)
rem Rename File
rem Enable Extensions
verify other 2>nul
if errorlevel 1 goto ErrNoExtensions
rem Set current Date & Time variables. Change the following lines to get the correct info out. For more info, use the DOS command: help set
rem Rename file
ren %1 %SHORTDATE%_%SHORTTIME%.*
echo Extensions not enabled. Cannot continue.
I am looking to make a similar script, but mine needs to capture the output of a small dos application i have created and rename the file to that output.
I want file.txt to be renamed to OUTPUT, but i cant figure out how. Thanks in advance.