/ 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
Copy this code and paste it in your HTML
@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 REM Create the Renamed_Files directory on the user's desktop if it does not exist. ) 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 for /f "tokens=*" %%b in ('dir /b') do ( REM ren "%%b" "%XDate% REM 3rd way of renaming ) 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. ) echo. dir /b goto END :WINDOWS ECHO. 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 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.