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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -