@echo off rem -------------------------------------- rem Check parameters rem -------------------------------------- if %1% == "" ( call :usage pause exit ) if "%2%" == "-no_ask" ( set noask=1 ) else ( set noask=0 ) if NOT EXIST %1 ( echo Error: file not found "%1%" pause exit ) rem -------------------------------------- rem get file info rem more info -> HELP CALL rem -------------------------------------- set file_path=%~dp1 set file_name=%~nx1 rem -------------------------------------- rem get time rem -------------------------------------- set date_tmp=%date:/=% set time_tmp=%time: =0% set yyyy=%date_tmp:~0,4% set yy=%date_tmp:~2,2% set mm=%date_tmp:~4,2% set dd=%date_tmp:~6,2% set hh=%time_tmp:~0,2% set mi=%time_tmp:~3,2% set ss=%time_tmp:~6,2% rem set sss=%time_tmp:~9,2% rem set time_stamp=%yyyy%_%mm%_%dd%_%hh%%mi%%ss% set time_stamp=%yyyy%-%mm%-%dd%-%hh%%mi%%ss% set file_new_name=%time_stamp%_%file_name% rem ---------------------------------------- rem ask user rem ---------------------------------------- echo Change: "%file_path%%file_name%" echo To: %file_new_name% if "%noask%" == "0" ( set /p ask=Continue? [y/n] ) else ( set ask=y ) if "%ask%" == "y" ( rename "%file_path%%file_name%" "%file_new_name%" echo Filename is changed. pause exit ) :usage echo Usage: Auto rename "file" to "YYYY_MM_DD_HHMISS_file" goto EOF rem ======================================== rem Finish. rem ======================================== :EOF echo Bye.
Sunday, December 22, 2013
自動でファイル名の先頭に日付時間情報を付加
ファイル名の先頭に日付を自動でRENAME
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment