imagine that I have 2 folders:
- C:\FolderData (will be incremented daily with new files)
- C:\FolderTemp (Needs to have only files from the day before executing, excluding hours/timestamp)
The FolderData will receive filenames that if not for date would be equals, as in:
- SYS_PURCHASES_20170612.xls
- SYS_PURCHASES_20170613.xls
- SYS_PURCHASES_20170614.xls
If I run the .bat file today I need that only the SYS_PURCHASES_20170613.xls be copied over to FolderTemp.
I tried using robocopy
but apparently it can't receive the same value for minage and maxage
robocopy "C:\FolderData" "C:\FolderTemp" /minage:1 /maxage:1
Also, if I try:
robocopy "C:\FolderData" "C:\FolderTemp" /minage:1 /maxage:2
It will bring both SYS_PURCHASES_20170612.xls and SYS_PURCHASES_20170613.xls, which is not what I need.
Other than that, I tried using forfiles
but also with no avail.
forfiles /p C:\FolderData /D -1 /C "/C /copy /y @file C:\FolderTemp"
or even
forfiles /p C:\FolderData /D -1 /C "/C /copy /y C:\FolderData\@file C:\FolderTemp"
And other variables but it returns something along the line "the system can't return the specified file" times the number of files in the folder.
Note that there are other processes involved bellow that should be ignored, It's just that I can't figure out how to do the step above.
All steps my batch filed needs to do:
- Copy from folder1 files from 1 day prior to folder2 (what I need help)
- Remove last 9 digits from all files from folder2 (will remove the date, used the loop on this solution) so the file will be SYS_PURCHASES.xls
- Move and replacing the files from folder2 to folder3 (using a simple
move /y
)