将当前日期添加到文件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将当前日期添加到文件相关的知识,希望对你有一定的参考价值。
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.
@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.
以上是关于将当前日期添加到文件的主要内容,如果未能解决你的问题,请参考以下文章