A bash script to convert the directory tree and image files created by iphoto in to a flat single directory.
A bash script to convert the directory tree and image files created by iphoto in to a flat single directory. This is useful for people who no longer use iphotos, and want to more easily view their old photos on a Linux computer. It copies the old files in to flattened version of the directory tree structure created by iphotos. It gives each file a unique name based on it’s location in the original directory structure.
If the input source directory contains directories and files like this:./pictures/iPhoto Library.photolibrary/Masters/2014/11/23/1234/birthday.mov,
./pictures/iPhoto Library.photolibrary/Masters/2016/03/16/1234/barbecue.jpg,
./pictures/iPhoto Library.photolibrary/Masters/2017/09/03/1234/beach.png
This script will output the following in to the destination directory:2014-11-23-1234-birthday.mov,
2016-03-16-1234-barbecue.jpg,
2017-09-03-1234-beach.png
./convert_files.sh
by default (Meaning no source or destination directory arguments given) is run in test mode. Test mode will create a ‘Masters/‘ directory and a ‘converted_files/‘ directory in the current working directory. ‘Masters/‘ will contain 4 folders, with 5 jpgs located in the end/bottom directory of each. Test will then copy/rename the 20 files over in to ‘converted_files/‘.
I recommend you try out the test mode first, to make sure it works the way that you want it to.
1) Clone the repository locally to your machine.
cd ~\myNewDirectory
git clone https://github.com/ryanpaixao/iphoto-dirtree-to-flat-tree
2) Go into newly cloned repository’s directory
cd ./iphoto-dirtree-to-flat-tree
3) Run the convert_files.sh script in the default test mode
./convert_files.sh
y
4) Check that the test mode created the source directory ‘Masters/‘ and the destination directory ‘converted_files/‘
ls
to see that both directories are presentcd ./Masters
to check ‘Masters/‘ directory contains 4 directoriescd ../converted_files
, and see that there are 20 files present (created from 4 different folders containing 5 files)cd ..
5) Once you have check that test worked sucessfully, run the convert_files.sh script. Make sure to supply it with the source directory location and the destination directory location.
./convert_files.sh ./my/old/source/directory ./my/new/destination/directory
6) Check your destination directory. All you files should be there, copied over, and renamed!!
Before the copying process starts, a ‘convert_files_error.log’ file is created with the time and date at the top of the log. If an error occurs during the copy process, the source and destination paths/name will be recorded in the log. Check the log after the copying is finished.
1) If you attempt to run ./convert_files.sh
and you get an error message saying “Permission denied”, do the following:
sudo chmod 755 ./run_first.sh
./run_first.sh
sudo ./convert_files.sh
. It’s possible that your source directory requires higher permission levels to have the files copied.