Sometimes you need an emergency reminder about how to find all files of a certain name in a directory structure… like say: find all .htaccess
files hidden in my web site. Well, here’s the magic command:
find . -name ".htaccess"
Also if you want to look for all hidden files (all files starting with a dot), you’d go like this:
find . -name ".*"
Using this to find images in iPhoto or Aperture
Sometimes you want to find the original or a preview of an image that is in your iPhoto or Aperture Library but you just can’t find it when you click on “Show Package Contents”. The above command is your savior. Just execute it from within the library folder and it will find any JPG file you know the name of in a matter of seconds.
How to automatically copy out the images you find
Now let’s assume you can use this command to find lost files in your library, here’s an example of how you copy them out:
cp -v `find . -name "IMG_542*.jpg"` ../recovered_files
Note the backquotes (back ticks) are used to reuse the results of the find
command as arguments to the cp
command. This is called “Command Substitution” in the shell.