So, I have a .bat file which copies three files (*_nc.csv, *_tx.csv, & *_west.csv) to a few corresponding sub-folders (\NC, \TX, & \West, respectively). When it copies the files, it appends " - yyyymmdd" (where yyyymmdd = %today%) to the end of the filename (without the quotes, with the spaces & before the .csv extension). This process runs at noon, whether or not I'm logged into the computer.
Unfortunately, I have not been able to find a successful way to have my batch file calculate the date for %yesterday%. As I understand it, without tons of code, it will calculate the day before the 1st of the month as 0; of course it should be something like 20081231, not 20090100.
Below is an excerpt of the .bat code:
- Code: Select all
cls
ECHO OFF
@For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @(
Set Month=%%A
Set Day=%%B
Set Year=%%C
Set All=%%C%%A%%B
)
@For %%a in ("\\SOMESERVER\SOMESHAREDFOLDER\SOMESUBFOLDER\*_nc*.csv") do copy %%a "\\SOMESERVER\SOMESHAREDFOLDER\SOMESUBFOLDER\NCA\%%~na - %All%.csv"
@For %%a in ("\\SOMESERVER\SOMESHAREDFOLDER\SOMESUBFOLDER\*_tx*.csv") do copy %%a "\\SOMESERVER\SOMESHAREDFOLDER\SOMESUBFOLDER\TX\%%~na - %All%.csv"
@For %%a in ("\\SOMESERVER\SOMESHAREDFOLDER\SOMESUBFOLDER\*_west*.csv") do copy %%a "\\SOMESERVER\SOMESHAREDFOLDER\SOMESUBFOLDER\West\%%~na - %All%.csv"
REM PAUSE
After multiple failed attemps to calculate %today%-1 (or rather, %yesterday%), I turned to the Bulk Rename Utility found here. Having used it before (to rename a batch of scanned images at once, with a sequential numbering system), I just *knew* there had to be a way to do what I'm wanting to do.
By the way, KUDOS to the developer on this app. It's highly customizable and powerful.
I found the option to use Century dating, and to offset by -24. However, I'm wondering if there is a way to have BRU look at the date value of the end of the file name, and remove 1 day?
Edit:
An example of the output filenames would be: "abcdefghij_nc - 20090101.csv", "abcdefghij_tx - 20090101.csv", & "abcdefghij_west - 20090101.csv". These would each need to be changed to "abcdefghij_nc - 20081231.csv", "abcdefghij_tx - 20081231.csv", & "abcdefghij_west - 20081231.csv".
Also, I'd like to find some way to script this. I believe that the BRU-CLI will handle this, but unfortunately the syntax is a bit too complicated.
Many thanks to any that can help!

Sincerely,
RMason
FezzikJr