Moving old images/files

Here’s a simple one for you. I had a directory with tens of thousands of files (images) and I needed to clean it up by moving all the images with a time stamp of 2016 or earlier into another directory.

Step 1 was figuring out how many days it has been between today and 12/31/2016 using this tool:

I came up with 618

Step 2 was running this command:

find . -maxdepth 1 -mtime +618 -type f -exec mv "{}" ~/www/images_bak/uploads \;

. = current directory
-maxdepth 1 = don’t go into subdirectories
-mtime +618 = files more than 618 days old
-type f = files only, no directories
-exec mv “{}” = we want to move the files, not remove them
~/www/images_bak/uploads = directory we want to move them to

Credit for this solution goes to user Jenny D at

I re-write these things cuz I can never find them twice… LOL

Excluding a directory when creating a tar file

So this is a dumb one but it took me longer than expected to find an answer.

So say I want to make a local copy of a wordpress site. I want to tar up all the files to download because downloading the files one by one will take hours and hours.

Assuming a directory structure like


I would normally go to /www and do

tar -zcvf mysite.tar.gz public_html

That gets everything…much faster to ftp.

But on some of our sites, we wind up with a BIG cache and I really don’t need all that stuff. In our case the cache is at:


So how to exclude the cache files? There’s an –exclude flag for tar but it seems finicky. Turns out it has to be the first parameter, at least for me and some others.

So this worked for me:

tar --exclude='public_html/wp-content/cache' -zcvf mysite.tar.gz public_html

This did NOT work for me
tar -zcvf mysite.tar.gz public_html --exclude='public_html/wp-content/cache'
Nor did this:
tar -zcvf --exclude='public_html/wp-content/cache' mysite.tar.gz public_html

–exclude seemed to only work when it came first after the tar command.