Creating a MacOS or Windows to Google Photos Workflow Using ExifTool

William Infante
7 min readJan 9, 2021
Photo by Brigitta Schneiter on Unsplash

I’ve been searching for the most convenient ways of storing photos that works for me. Google Photos came very close as I like the search features and UI, but it’s still missing the info found in the local folders where my photos are grouped. In addition, I also wanted a seamless validation of the dates in my photos based on the folder group. Downloaded photos from Facebook have no date taken info. Given these, I’ve created a workflow using bash scripts and the ExifTool from Phil Harvey to streamline the syncing of my MacOS/Windows photos in single-level folders to Google Photos.

Preserving Info in Local Folders

I usually keep my photos arranged chronologically in single-level folders. For example, I may have a folder named `2020.12.15 Fraser Island Camping` but once I upload the photos to Google Photos, the folder name information is lost. If I get a lot of folders, I’ll probably grouped these folders further per year like in a `2020` folder, but the essential information I need is still in single-level folders. The single-level arrangement has been convenient for me as I can just drag and drop these folders simultaneously when I upload them to Google Photos.

Here’s the main problem now: I want the information like `2020.12.15 Fraser Island Camping` always linked to the photo I upload in Google Photos.

Photo by Rajeshwar Bachu on Unsplash

Previously, I can use the Google Drive — Google Photos shared connection. I upload my photo folders to Google Drive and when I search them in Google Photos, I can still search the folder names. But… this became problematic when I needed to delete my photos and folder in Google Drive. The folder info also got deleted in my Google Photos. Furthermore, I don’t want to involve too many services — just Google Photos for my online photos.

Image by author

Others may suggest that I can just create an Album in Google Photos but that would mean a lot of manual work. Definitely better than changing the Info in each photos but still a lot of manual work! I have to upload the photos folder by folder and then type the same info I already had in my local Windows or MacOS folders. Another problem I find here happens when I need to update or add a photo in a folder. What I have in my Google Photos are not synced with what I have in my local folders.

Image by author

Some may argue too that the search functionality from Google Photos may suffice. It’s true that if the EXIF data such as the location are properly placed, Google Photos may detect the photos by just searching “Fraser Island”, “Camping”, or “2020.12.15”. I can even find these photos in other search keywords like “tents” and “Australia”. But… there will be times (often) where I am placing keywords in the folders that are only relevant to me personally or sometimes I would even use non-English language words as part of the folder name. Photos taken say from Facebook may also not have the location information.

Photo from Microsoft
Image by author

I did find a workaround with my Windows environment. I could copy the folder name, select the photos inside the folder and replace by batch the Title info. When these are uploaded to Google Photos, the folder name now becomes part of the Google Photos Info description. On a side note, the batch feature in Windows does not work for PNG files, only JPEG files. As you can seek, there’s quite a lot of manual work already here.

Photo from Apple

And when I shifted to MacOS, it became more problematic. I don’t have the batch feature for changing the Title or description in Finder. If I really want to, I had to grudgingly open my Windows environment just to add this batch info in my photos. There has to be a better way.

The ExifTool looks promising as I was able to manipulate my photos to change the title based on the top-level folder name as in `fnc_overwrite()` in the shared gist below.

But I wanted more granular control. For example:

  • changes should apply only to JPEG and PNG images
  • if the photo does not have the title yet, go ahead and change the title or description based on the folder name
  • if the image title or description is the same as the suggested title or description from the folder name, don’t make any changes to the image and continue checking other images
  • if there is already a title or description but it does not match the suggested the title, I’d like to see the current and suggested titles and give me the option to overwrite the title or not

These specification are met by the script below:

Date Validation from Folders

I also have another problem for date taken info in my photos (seems I have lots of problems with photos). If I download a photo from a social media site like Facebook and include those photos in my local folders or if I took screenshots from the laptop, those photos do not have the `date taken` set. That’s problematic for me when I need to search the photos by date. In addition, Google Photos arranges the photos by dates too and those photos will be misplaced.

Using the ExifTool, whether I’m using MacOS or Windows for my environment, I can create a script to check images with missing dates.

If we want the to update the date in a single image file (without regard to the time that we temporarily place say at 12:00:00), a simple script like this would do:

But as you can see, running the check script and single change date scripts like this repeatedly is problematic. It does not support multple files (or multiple folders) at once for changes and we have to manually enter the date we would to use. In the way I have arranged my folders (remember `2020.12.15 Fraser Island Camping`), I already have the expected date in the folder name. If we want to streamline this, I shouldn’t be typing the date again when we can extract that information from the folder name.
First, we should only be looking at folders with valid dates. That is, the folder name should have the pattern `DDDD.DD.DD` where D represents a digit. Much better, we add checks that the months are from 1–12 and the days are from 1–31 as in below:

is_matching=$([[ $my_date =~ ^[0-9]{4}\.(0[1-9]|1[0-2])\.(0[1-9]|[1-2][0-9]|3[0-1])$ ]] && echo "matched" || echo "did not match")

Much like the title naming, I’d like to have granular control of the changes:

  • applies only to JPEG and PNG images
  • if the photo does not have the date yet, change the date the same as the suggested date from the folder name
  • if the date in the photo is the same as the suggested date in the folder, don’t make any changes and move on to the next image
  • if there is already an existing date taken, I’d like to see the suggested date and give me the option to overwrite the date

As I was going through my folders with a beta script, I noticed that the script could be made more efficient if I have the option to skip inconsistent dates within a folder and then move on to the next folder to check the dates. For example, I may have a folder `2020.01.23–24 Sydney Picnic` where some photos may have the dates `2020.01.24` which is not the same as the suggested date `2020.01.23`. For other instances, due to timezone differences, some photos may also be labelled with `2020.01.22` but are still qualified for the `2020.01.23–24 Sydney Picnic`. If I have tens or hundreds of photos with this issue in the same folder, I’d rather have the option to skip checking dates for that folder, but still continue checking for other folders. That’s why in the script, I have three options Yy/Nn/Ll:

  • Y will change the date of the photo based on the suggested folder date,
  • N will skip the image and move on to the next image, and
  • L will skip all the remaining until the last image within the folder but still check other folders for date inconsistencies.

Future improvements in the script should probably consider a range of date values accepted for the suggested folder, but the current state is already useful for my use cases.

Here’s the working script:

Script Combinations

Interestingly, the two scripts can be used in tandem to detect organization errors in my photos. I may have a folder named `2020.10.20 Berowra Bushwalking` and when I ran the date validation script, the images inside this folder have dates `2020.01.20`, so I could easily spot that I made a mistake in naming the folder. Initially, I only wanted a way to streamline a workflow for my local photos to Google Photos and the scripts had this other effect of detecting potentially wrong folder names or misplaced photos.

Parting Note

So there you have it, after the scripts have run, I can just drag and drop the folders simultaneously to Google Photos and have them synced as expected. Admittedly this may not work for your own photo workflow and structure, but hope it gives you an idea how you can supplment current photo services with scripts you can use. Happy scripting!

https://github.com/williaminfante/photos_workflow

--

--