Link to home
Start Free TrialLog in
Avatar of Robert Thun
Robert Thun

asked on

How do I create a Robocopy script that will copy new files from folder A to folder B then delete files on folder A that are older than 365 days.

How do I create a Robocopy script that will copy new files from folder A to folder B then delete files on folder A that are older than 365 days.

Here is my current script to copy
C:\WINDOWS\system32\ROBOCOPY.EXE "D:\Folder A" "S:\Folder B" *.* /NP /B /Z /E /R:10 /W:30 /M /copyall /V /COPY:DT /LOG:Audioback.txt

I would also like the script to let me know which files were deleted in folder A.

Bonus would be to have script also zip the deleted files.
SOLUTION
Avatar of Bxoz
Bxoz
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robert Thun
Robert Thun

ASKER

Will that send me a list of the deleted files?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks I will test this.
I tested this and it is not deleting the hidden files in the structure. Any way to curtail this issue?
Was thinking this?
forfiles /p D:\Folder A /s /m *.* /d -365 /c "cmd /c del /a:HR @file && echo @path >> C:\Path\To\Log.txt"

Also is there a way to verify that the file is in Folder B before removing it from Folder A?

Is this script looking at modified or created date?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial