Linux Blog

Cleaning Up Files & Directories

Filed under: Shell Script Sundays — TheLinuxBlog.com at 8:30 am on Sunday, August 19, 2012

While not really a shell script as such, this is shell related and  it just so happens to be Sunday.

Find Empty Directories:

find . -type d -empty > empty_folders.txt

Find Empty Files

find . -type f -empty > empty_files.txt

The issue with these two commands is that within my jumble of unorganized mess I have an abundance of version control repositories (mostly SVN) and tons of source code with empty, but needed directories. Fear not if you have the same problem, you can filter them out by using:

grep -v empty_files.txt svn

Duplicate File Removal

There are multiple ways to remove duplicate files. I used to think a  recursive md5sum script was the way to go but that was before I found the utility fdupes.
Install via your package manager if it’s available and use recursively like:

fdupes -r [directory] > duplicates.txt

With fdupes you also have the ability to symlink or delete files, although because of the amount of source code, I’d rather review it manually.


With these utilities I was able to merge copies of photos remove a bunch of old files and empty directories and am one step closer to being digitally organized. If you have the same problem, hopefully they will help you too. If you have any cleanup or organization tools, please comment and let me know.

rsync to smb share

Filed under: General Linux — TheLinuxBlog.com at 4:30 pm on Thursday, September 11, 2008

If you happen to have a SMB share with a lot of disk space laying around, then you may have considered backing up to it. There is more than one methods that you could back up to a SMB share but this article will show how to rsync to a smb share. This blog post assumes that you have successfully set up your SMB share and have installed RSync.
(Read on …)