Robocopy only copy folders modified in last 7 days - robocopy

I'm trying to create a robocopy program that runs every Sunday and pulls in the last 7 days of folders(and its sub-folders) .this is because the folder stores years' worth of data so I only want to pull in the new folders.
is there a way to do this? I've been playing around with the max/min age but its pulling in all folders
what i have so far:
robocopy \\myserver\test\main_folder \\myserver\test\main_folder_archive /MIR
I want to run this every Sunday and it is smart enough to pull in the last 7 days.
Any help is appreciated, thanks

robocopy \server\source_share \server\dest_share /MAXAGE:7 /S /E
Should do it. This is not compatible with /MIR though:
/MIR :: Mirror a complete directory tree.
So either mirror, or select 7 days worth of files.
Edit: added /S, which is what I think was the desired switch instead of /MIR

Related

robocopy to preserve some extra files

I have a problem with robocopy and with extra files in particular.
I would like to run robocopy to keep two directories almost in "sync" and thus it would be natural to use the /MIR option along with /MON:x to keep the process alive.
I need to copy a list of files, let's assume for example *.tif, from SRC to DST and it is ok when robocopy is removing from DST extra files that matches the file pattern.
But with the /MIR option, robocopy is removing all extra files even if they are not matching the *.tif
I tried to use the /XX option, but this is actually preserving all extra files. I believed I could add a path or filename to the /XX but it is not accepted.
I tried to use the /XF *.png option in order to exclude the png files, but this is only applied on the SRC and not on the DST.
Does a solution to this problem exist?
Thanks in advance for your help,

How to perform two ROBOCOPY statements from one source folder to two destination folders in one batch file?

I have an interesting situation where I'd like to move some files from directory X to directory Y, but in order to MOVE the files without deleting the source folder, I created a log statement in said folder. A very simple version of what I'm doing is this:
robocopy
"C:\Desktop\Origin" "C:\Desktop\Destination"
/e /move /XF "C:\Desktop\Origin\test.log"
/log:"C:\Desktop\Origin\test.log"
This results in the moving of all files in "Origin" directory to "Destination" directory, and doesn't get rid of the "Origin" directory, as the "/e /move" flags normally would. Now, if I didn't want that log file, I could simply add this line to the code:
del "C:\Desktop\Origin\test.log"
But, I actually do want to keep this log file. I just want it somewhere else. So what I've been trying to do is to move it to directory Z with "/e /mov" or even just "/s" and then the delete. For example:
robocopy
"C:\Desktop\Origin" "C:\Desktop\Destination"
/e /move /XF "C:\Desktop\Origin\test.log"
/log:"C:\Desktop\Origin\test.log"
robocopy
"C:\Desktop\Origin" "C:\Desktop\Destination 2"
/s
del "C:\Desktop\Origin\test.log"
But after trying multiple times, with multiple little variations, nothing seems to happen. The first robocopy happens, but the second doesn't seem to happen at all. It seems like multiple robocopy statements can run in one batch file (which is what I want) but perhaps not from the same source directory. Does anyone know why this is the case and also how I can achieve my stated goal? Thanks!
Thanks to the suggestion of Ken White, I found a solution to this. If you use MOVE.EXE, it works just as expected.
robocopy
"C:\Desktop\Origin" "C:\Desktop\Destination"
/e /move /XF "C:\Desktop\Origin\test.log"
/log:"C:\Desktop\Origin\test.log"
move
"C:\Desktop\Origin\test.log" "C:\Desktop\Destination 2"
One thing to note is that you can't use /LOG+: with this method, since you'd be writing the log file to a location where no log file exists, since it had been moved previously to "Destination 2". However, even the normal log files include the *EXTRA files already in the directory.

Is there any batch command to move files and delete empty sub folders

Anyone know of a simple batch command to move files and delete empty sub folders? Just got a new external and when I copied everything over it resulted in something like this. F:\Music\John Denver\John Denver\files1-10 F:\Music\TheBeatles\TheBeatles\files1-10 and so on, for say, 350+ folders. I don't want to waste that much time manually moving them up one folder and deleting sub folders... Not all files are same file type, and not all folders are music. Some folders have other sub folders that I want to keep (mostly for music files, such as artist\album\files) Is there a way to do this instead of the old fashioned way? Any help is appreciated.
You can use ROBOCOPY.
ROBOCOPY source destination /S /MOVE
/S flag is used to exclude empty subfolders.
ROBOCOPY "F:\Music\John Denver\John Denver\files1-10" "F:\Music\TheBeatles\TheBeatles\files1-10" /S /MOVE

ROBOCOPY puts the date 1/1/1980 on some copied files

I am having an intermittent issue with ROBOCOPY copying files with an incorrect date.
I am using ROBOCOPY to copy backup files from a local folder to a remote fileshare as a part of having a remote backup solution. The script is scheduled through task manager to run daily. Here is pseudo code:
ROBOCOPY E:\LocalFolder \\RemoteServer\FileShare\Folder *.bak
Most of the files copy with the correct file date, hovever one or two files sometimes will have the date of 1/1/1980. This presents a major issue with managing the backups in the fileshare because the dates are crucial to its management.
What might causes this?
What can be done to prevent this behavior?
I was having a similar issue. After some searching, I found reference to a behavior of Robocopy where it sets the modified date to 1/1/1980 until after a transfer is completed. [source]
What was really strange in my case was, if I watched the directory during the copy, I would see the file with the correct date appear, then AFTER it was complete the date would change to 1/1/1980. After some experimentation, I removed the /B switch I had been using and the dates seemed to be left alone.

Batch File to Automate backup folders

So, I currently have a Drobo server that houses a Backup folder for customers that need to have their Hard drive files backed up. I create a folder for each customer in this backup folder. It's our policy to keep these files for our customers for 30 days, after which, need to be deleted. I'm wondering if its possible to make a batch file that can scan the entire Backup folder, each folder for each customer ONLY, not all the files, just the folder by modified date and if it is older than 30 days, move the entire folder that I'll label Delete for further review before deleting. I'm going to make a second batch file to delete all the folders and files once inside that delete folder, but I need the first batch file that scans just the folders' modified date in order to determine if it needs moved first. Any help would be appreciated. Thanks.
Forfiles /P C:\test\ /D -30 /c "cmd /c move #file c:/delete"
just an example of script you might use

Categories