[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More


Finding files in shared drives that have not been used recently

Published on
9,309 Points
1 Endorsement
Last Modified:
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"

Open in new window

/s = Hunt down through the folders.  You could use /e to also move empty ones and create a copy of the full structure.
/MOVE = Move the files (if you did not specify this it would copy and not remove the existing ones)
/MINAGE:20100101 = 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
/r:1 /w:1 = retry locked files just once and wait for 1 second between retries.  Make this more / longer if needed.
"P:\FINANCE-FOLDER"  = the folder we are going from
"P:\Archive" = 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
1 Comment

Administrative Comment

by:Eric AKA Netminder

Your article has been published.

Page Editor

Featured Post

Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

There are many cases found where ScanPST.exe fails to repair corrupt Outlook PST File. When user tries to repair PST using Inbox Repair tool and it throws below error: •      Inbox Repair tool does not recognize the file •      ScanPST.exe hangs in betwee…
I've published three five-minute Experts Exchange video Micro Tutorials that describe terrific features in an excellent, free PDF product called PDF-XChange Editor: How to rotate pages in a PDF with free software (https://www.experts-exchange.com…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month