When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help.
This command will place all the files that have not been used recently into a folder but keep the directory structure in case you need to return any of them.
The first step is to check with the department that this can be done. Check they do not need to keep these files for historical or legal reasons. If they give you the go ahead then the next step is to make sure you have ‘robocopy’; you’ll find it in the Microsoft RKT
Robocopy is a copy/move program like xcopy but with far more powerful command line switches.
What I would like is for it to go through
and check each file for the last time it was used. If it has not been used after a date I set then move it with its existing folders into a new folder.
To start with I am making the folder outside the folder I am working on. If you made it inside in its final destination then you would get into a loop where it would start to search inside itself and move its files into itself (not good).
So here is the command :
robocopy /s /MOVE /MINAGE:20100101 /r:1 /w:1 "P:\FINANCE-FOLDER" "P:\Archive"
= Hunt down through the folders. You could use /e to also move empty ones and create a copy of the full structure.
= Move the files (if you did not specify this it would copy and not remove the existing ones)
= The date the files were last used (in the format YYYYMMDD so 29 may 2007 would be 20070529) You can also specify number of sys up to 1900 example /MINAGE:365
= retry locked files just once and wait for 1 second between retries. Make this more / longer if needed.
= the folder we are going from
= the destination.
When the copy is complete you get a summary saying how many files it moved / skipped etc.
Now you can move the file into the folder using the normal methods (like drag and drop)
What you do with it at this point is up to you. You could lock it down so only Sys Admin people can get in to bring back files that are needed. You could back up that file to tapes / disk elsewhere and delete it. You could set the compression bit on the folder so it takes up less room for these recently unused files.
This command works on any version of windows that has access to networked drives that can be accessed or mapped to. I have used it on Windows 2000, XP, Vista and WIndows 7 Workstations, and I have used it to attach to Windows NT4, 2003 and 2008 Servers