Batch script to RENAME file with current date -
i trying rename file replacing date in file name current date. getting "syntax incorrect error"
here code:
echo on /f "skip=1" %%x in ('wmic os localdatetime') if not defined mydate set mydate=%%x set today=%mydate:~0,4%-%mydate:~4,2%-%mydate:~6,2% set "_year=%mydate:~0,4%" set "_month=%mydate:~4,2%" set "_day=%mydate:~6,2%" ren c:\users\xyz125\documents\erics's docs\scripts\"test file (20150112).txt" "test file (%_year%%_month%%_day%).txt" pause
wrong quoting: instead of
ren c:\users\xyz125\documents\erics's docs\scripts\"test file (20150112).txt" "test file (%_year%%_month%%_day%).txt" rem ^
should be
ren "c:\users\xyz125\documents\erics's docs\scripts\test file (20150112).txt" "test file (%_year%%_month%%_day%).txt" rem ^
Comments
Post a Comment