/ Published in: DOS Batch
This is a batch file that will add the date to the end of all files in a particular directory located on the user's desktop and place them in a directory called Output_Renamed on the user's desktop.
Expand |
Embed | Plain Text
@echo off TITLE Add Date echo date to the files' name. ECHO. ECHO. ECHO. ECHO. goto START :START cls echo. echo. REM Get, cut and set the date variable. REM Depending on the user's answer from above do the following. REM Rename the files in the current working directory. :CURRENT ) ECHO. REM 1st way of renaming. Works if there is only one period. REM ren *.* ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????_%XDate%*.* REM 2nd way of renaming. Put the date on the front of the filename. REM ren "%%b" "%XDate% REM 3rd way of renaming ren "%%b" "%%~nb_%XDate%%%~xb" ) dir /b goto END REM Rename the files in another specified directory. :OTHER cls set /p DIRPATH=Enter the full path of the directory or q to quit: echo. ECHO. REM Do the following depending on the user's entry. REM This part is used to rename files that are located in another directory. :RENOTHER ) ECHO. ren "%%b" "%%~nb_%XDate%%%~xb" ) echo. dir /b goto END :WINDOWS ECHO. ECHO This is the Windows directory. Can't rename. ECHO. goto OTHER :NOTTHERE echo. echo. set /p TRYAGAIN=Would you like to try again? y/n :INVALID echo. goto END :NOINPUTDIR cls ECHO. ECHO want to rename to that directory. Otherwise, please specify a different ECHO directory to use. ECHO. set /p TRYAGAIN=Would you like me to create the Input_Renamed directory? y/n or d to specify another directory: :INPUTDIRCREATE cls ECHO that directory or specify another directory. goto START :END echo. echo. echo Exiting the program, HAVE A NICE DAY! echo.
You need to login to post a comment.
