Trying to get batch to rename files being archived with previous date - no experience or knowledge -


i'm trying resolve pain in ass task in work creating batch file archive , rename array of files 1 click.

currently i've got that, , works fine after google help.

there files require renamed previous days date. i've looked thoroughly , found several examples mean nothing me, have not clue i'm doing.

these systems locked down tight, , best can batch, nothing else. there batch solution this?

so example of archive , rename code i'm using simple:

copy "h:\my documents\test\test.txt" "h:\my documents\test\output\test.txt"  

ren "h:\my documents\test\output\test.txt" "%date:/=-%.txt"

so works fine.

i saw example:

    @echo off if /i "%date:~0,3%"=="sun" ( call :daysago 2 ) else (     if /i "%date:~0,3%"=="mon" ( call :daysago 1 ) else ( call :daysago 1 ) ) echo %year% %month% %day% 

and thought might able stuck in somewhere, doesn't anything, chances i'm failing understand how deploy bit of code.

any appreciated, don't know programming, don't know batch , other 'hi' lose me in terms of understanding!! :)

thanks,

cal

to yesterday's date, can use

for /f "usebackq" %%a in (`"powershell (get-date).adddays(-1).tostring('yyyy-mm-dd')"`) set yesterday=%%a echo %yesterday% copy "h:\my documents\test\test.txt" "h:\my documents\test\output\%yesterday%.txt"  

as can see, can adapt date format needs.

i used code npocmaka


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 -