Batch Insert Images to Google Sheets (Tutorial Macro)

Download The Macro Here (2025.05.12)

Troubleshooting:

I’ve been contacted by several people about this macro not working, due to things I hadn’t anticipated, such as Google updates and different versions of macOS. I’ve now managed to resolve these issues, so if you’re experiencing the same problems, please follow the steps below!

Finder Opening Instead of Google Troubleshooting

The action I screenshotted below is meant to switch back to Google Sheets in my macro. You need to select the first cell where you want the image before triggering the macro. When the macro runs, it opens Finder so you can choose your folder, and it should then jump back to Google Sheets as the last active app. However, I’ve heard from a few people that it’s jumping back to Finder instead of returning to Google Sheets like it does for me.

If this happens to you, scroll to the bottom of my macro, select New Action, search Activate in the search bar, and choose Activate a Specific Application. Replace Activate Last Application with this, then change the application from Finder to Google Chrome.

Google Update Troubleshooting:

Someone else mentioned that my macro inserts a chart and then fails.

We eventually learned that the issue was caused by a recent Google update. They added a Generate an image button and a Timeline button above the Insert image in cell button. This means the macro now requires two additional Down arrow keystrokes to reach the image button, plus one Down arrow keystroke between the two Return keystrokes.

If you have this update, you can fix the issue by adding the extra Down arrow keystrokes to your macro. Select one of the existing Down keystrokes under the screenshot of the Insert button, press ⌘ + C to copy it, then press ⌘ + V three times. Next, drag one of the new Down keystrokes so that it sits between the two Return keystrokes. You should now have ten Down keystrokes instead of eight, plus one Down keystroke between the Return buttons, as shown in the example below.

macOS Troubleshooting:

The last thing I hadn’t considered was which operating system people were using. When I made this video, I was on Ventura 13.7.6, but someone who couldn’t get the macro to work was on Catalina 10.15.7.

They got stuck after the macro pasted a file path, but it wouldn’t proceed any further. We discovered that this OS doesn’t handle double slashes well. For example, a file path like /Users/trainee/Desktop/THUMBNAIL TEST//0002.jpg wouldn’t work, even though it did for me. I had to modify the script so that there was only a single slash, resulting in /Users/trainee/Desktop/THUMBNAIL TEST/0002.jpg.

If the macro is failing at this point for you as well, delete the Shell Script at the beginning of the macro and replace it with the updated script below. This should resolve the issue and allow the macro to work correctly.

#!/bin/bash

# Prompt user to select a folder
folder_path=$(osascript -e 'tell application "Finder" to set folderPath to POSIX path of (choose folder with prompt "Select a folder")' | sed 's/^"//;s/"$//' | xargs)

# Exit if no folder is selected
if [[ -z "$folder_path" ]]; then
  exit 1
fi

# Remove trailing slash if it exists
folder_path="${folder_path%/}"

# Find all JPEG and PNG images in the folder (ignore files starting with ._), sort alphabetically by filename, and save full paths to /tmp/file_list.txt
find "$folder_path" -maxdepth 1 -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) ! -name "._*" -print | \
while read -r file; do
    echo "$(basename "$file")"
done | sort | while read -r sorted_file; do
    echo "$folder_path/$sorted_file"
done > /tmp/file_list.txt

# Count the number of image files
image_count=$(wc -l < /tmp/file_list.txt)

# Save folder path and image count to temporary files
echo "$folder_path" > /tmp/folder_path.txt
echo "$image_count" > /tmp/image_count.txt

# Notify via macOS notification center
osascript -e "display notification \"Folder selected: $folder_path with $image_count images\""

Leave a Reply