0

The company I work for has a shared network drive. On it, we have folders for each department, plus folders for each employee. There are tons of folders for employees who've left years ago, and I'm sure the same applies for the subfolders in the department tree.

I have run a disk usage scan, and I have a reasonable suspicion that we can save loads of disk space by purging obsolete data. But getting an overview of disk-usage-by-last-modified is an interesting challenge, which I have not been able to come up with a response for.

Any ideas? How can I obtain a listing of folders (at various tree levels) sorted by the date when they (or files in them) were most recently modified?

Update: This is for Linux, but there is no tag for "generic linux" (only Mint, Kali, and a few others).

KlaymenDK
  • 1,459

1 Answers1

3

Open File Explorer and navigate to the shared folder.

Press F3 key on the keyboard, you will see in search field drop-down menu, click on the
Date modified: under Add a search filter and choose time filter as you need. You can select search criteria from predefined patterns or type in the search field range of date as:

datemodified:‎1/‎1/‎2000 .. ‎8/‎22/‎2018

If you need to find files/folders that wasn't modified after some date, you can use < character in front of date:

datemodified:‎<1/‎1/‎2010

It will find recursively all files and folders that are older than 1/‎1/‎2010

When explorer stop searching, switch view to Details and press on column Date modified to sort found files and folders and delete those you thing are no longer in use.

You can also search by accessed or created date using search filter as:
datecreated:
dateaccessed:

If you want to automate removing of old content, you can use console utility: forfiles

To delete recursively folders/files that wasn't modified an year ago and later from folder C:\SomeFolder:

forfiles /s /p "C:\SomeFolder" /d -365 /c "cmd /c del @path"

If you want just list old files/folders instead of deleting them, you can use:

forfiles /s /p "C:\SomeFolder" /d -365  /c "cmd /c echo @path [@fdate]"

Use forfiles /? to get more info regarding this utility included with your windows

You can even create a batch file and run it via task scheduler to automatically delete old content.


P.S. If you want to find and remove old directories/files using Linux, it is much simpler:

To list old content:

#!/bin/sh

srcDir='/Path/to/share/'
daysAgo='360'

find "${srcDir}" \( -type f -o -type d \) -a -mtime +"${daysAgo}"

To remove old content:

#!/bin/sh

srcDir='/Path/to/share/'
daysAgo='360'

find "${srcDir}" \( -type f -o -type d \) -a -mtime +"${daysAgo}" -exec rm -fd '{}' \;

If you want to remove directories recursively use rm -fdr in place of rm -fd

Alex
  • 6,375