Original Content

A Couple of Not Totally Useless Things You Can Do on the Command Line [written for beginners]

As a librarian who has been very engaged in the movement to demystify programming, I’ve really focused on teaching and sharing tools that users can use in daily life, as that has been the most common question I get when teaching, “When will I use this?” This post has been heavily influenced by my work in teaching programming to the non-programmer and teaching something that can be applied beyond the classroom.

With the start of school on the cusp (and for some already come and gone) I wanted to throw something not totally useless out there for you to tuck away to use on a rainy day or now if you’d like.

These have been written in mind that you may have some, experience with the command line but very little. I apologize for those more experience users if this is a bit dense in explanation.

I’ve ran these successfully on both MacOS X Yosemite and Linux-Ubuntu. This is my first attempt at providing documentation on something like this, so please feel free to critique it.

If you are a Windows user, I recommend downloading Console2 [http://sourceforge.net/projects/console/], which is a terminal-emulator that will allow you similar access to the commands used in Linux and MacOS X

For this documentation anything following the $ is what you will type into your command prompt. The $ denotes a new command to be entered on a new line, some commands wrap, but do not hit enter until you’ve type the entire command. For the most part, you can copy and paste the command directly into the terminal, but make sure you make the necessary changes.

Use Find and Exiftool to gather & organize all of your pictures by creation date into folders by year and month


This will walk you through full install of Perl, Exiftool, directory creation and processing of files. Exiftool is a really handy tool for reading, writing and editing metadata in a significant range of file types, so it is a really great tool to have in general.

First you’ll need to install Perl and exiftool. There is a high possibility that your computer will already have Perl installed, but in the case that it doesn’t you will need to install it.

To check to see if you have Perl installed use this command:

$ perl –v

If it is installed, you will get information on the version of Perl you have installed and you can skip the next command.

If it is not installed you will need to install it.

$ curl –L http://xrl.us/installperlosx | bash

Installing exiftool For full Perl distribution, download the Image-ExifTool distribution from http://owl.phy.queensu.ca/~phil/exiftool/index.html to your desktop (if you do not specify where to download it, then cut & paste the download from the downloads folder to your Desktop) and then in your terminal run the following.  **You will be using sudo on one command, please be VERY careful with this as it can do some major damage if not used properly.**

$ cd ~/Desktop
$ tar -xzf Image-ExifTool-9.99.tar.gz
$ cd Image-ExifTool-9.99
$ sudo cp -r exiftool lib /usr/local/bin
$ [PASSWORD]

Don’t want to use the terminal to install this? Go to http://www.sno.phy.queensu.ca/~phil/exiftool/index.html and download the version you need and install it as a normal package.

Anytime you want to run exiftool, you call it up by typing exiftool into the command line.

Now we need to make the folder to compile all the images we want to sort into one place.

$ cd Documents
$ mkdir “newfoldername”
$ pwd
$ cd ~

Replace “newfoldername” with the name of the folder you want to create and use.

pwd will give you the directory pathway for Documents/newfoldername you will need in the next few commands so make note of it, copy it or write it down.

We are going to find all of the JPG files on your computer and put them into that folder you just created. The tilde (~) denotes home directory which will search your entire computer; if you have all of your photos in another directory you can use the pathway for that instead.

This command will find in your computer all files with extensions .JPG and .jpg and copy them to the new specified folder retaining the original files & their modification information. It is important to compile them in one folder so you can run exiftool much more quickly.

$ cd ~
$ find ~ -iname ‘*.jpg’ -print -exec cp –pr ‘{}’ Documents/newfoldername ;

If you want to search other file types like .png, then replace the JPG with png.

If you need to be case sensitive on the extension, remove the i from –iname.

Replace “Documents/newfoldername” with the pathway to directory you just created (noted from pwd command)

Using Exiftool to organize all the files into folders by year and month using this line of command.

$ exiftool ‘-Directory<CreateDate’ –d
$ Documents/newfoldername/%y/%y%m –r Documents/newfoldername

Replace both instances of Documents/newfoldername directory with the directory you created.

Use Exiftool to sort all of your files by create date and then into folders by year and month


If you just want to copy and sort all of your files into folders, not specifying file types run this command instead.

$ Exiftool –o . ‘-Directory<CreateDate’ –d Documents/createfolder/%y/%y%m –r ~

This will search the entire root directory, and any file types that can be copied will be copied and organized by creation date in the folder you specify.

Keep in mind that Exiftool is not limited to moving only image files so you can play around with this as you want.

Send a text message from your command line with this script:


$ curl http://textbelt.com/text -d number=########## -d “message= your text message goes here”

Where the ########## is your 10 digit number and your message goes after the message= and closed with a “

If you are going to send notifications to your phone often you can add it as a quick command:

$ SendText () { curl http://textbelt.com/text -d number=########## -d “message=$*”;echo message sent; }

Now anytime you want to send a text to that number input into the command line:

$ SendText your message goes here

You can also run this as a module or a standalone server, see GitHub source here: https://github.com/whitni/textbelt

This can be used to send notifications to your phone when running a program. Currently, I just use it to send the grocery list to myself, cause you know there is an app for that.

Here is a write up of an example of something you might want to receive text notifications on: http://adambuchanan.me/post/29018724579/fun-with-textbelt-public-sms-api