I've been searching a lot about how to convert a string into a integer on windows batch but I just can't get how to do it.
I've written a batch that copies a file from a directory to another and name it after the current date. My code goes something like this:
set FILE=log %date:~6,4%-%date:~3,2%-%date:~0,2%
copy C:\log.txt C:\"%FILE%".txt
I need to do the conversion to make FILE be one day previous. For example, if I run the script right now, I'll get a file named "log 2014-07-09", but I want it to be "log 2014-07-08".
I've tried with this few sentences but I get an error about the numeric value is not valid:
set DAY=%date:~0,2% :: this assignation give me no problems
set /A DAY = %DAY%-1 :: this is the one that makes my head breaks
I don't know where the error is because I barely know windows batch sentences. I've read about the SET command syntax at Help command and other sites (like this one) but I can't get where I'm failing. I know this may be very simple (on some programming languages a Parse sentence would be enough), but I'm a total novice on this batch script stuff, so any help will be much appreciated. :)
"{0:yyyy-MM-dd}.txt" -f (get-date).AddDays(-1).log /07/- 1-Thso your copy command iscopy C:\log.txt C:\"log /07/- 1-Th".txt. That does not look right.