Skip to content

Remove json suffix "supplemental-metadata" #375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Wacheee
Copy link

@Wacheee Wacheee commented Feb 10, 2025

Added an option to remove the "supplemental-metadata" and its variants ("supplem", "supplementa", etc) suffix from JSON to prevent issues with metadata before gpth run the copies/move functions. Fixes: #353

@Jazza-231
Copy link

Don't you just love it when companies change stupid things like this? Thank you for the fix @Wacheee this directly made this tool perfect for my use, lgtm

yes i am just a random person who has no authority to say "lgtm" i am also not professional

@alerivo
Copy link

alerivo commented Mar 27, 2025

This fix worked for me too! The new json suffix "supplemental-metadata" were making troubles for the script to work

Thank you @Wacheee

@astronyu
Copy link

This works better, till a point where a lot of videos still shows up in the date-uknown folder.

@jklanica
Copy link

I noticed a potential issue with the current renaming logic that may cause file name collisions.

Specifically, when there are multiple image variants like:

  • IMG_20210704_094147.jpgIMG_20210704_094147.jpg.supplemental-metadata.json
  • IMG_20210704_094147(1).jpgIMG_20210704_094147.jpg.supplemental-metadata(1).json

both end up being renamed to IMG_20210704_094147.jpg.json, which causes the second one to be skipped, since the filename already exists.

In my own version, I updated the regex to optionally capture the numeric suffix (e.g. (1)) to keep the filenames unique:

final regex = RegExp(
  r'^(.*\.[a-z0-9]{3,5})\..+?(\([1-9][0-9]*\))?\.json$',
  caseSensitive: false,
);

Then I used:

final newName = '${match.group(1)}${match.group(2) ?? ''}.json';

This way, the renamed files become:

  • IMG_20210704_094147.jpg.json
  • IMG_20210704_094147(1).jpg.json

This avoids skipping and preserves the distinction between file variants.

@DebuggerDave
Copy link

DebuggerDave commented Jul 26, 2025

The way I implemented it is to add another name mangling function in json_extractor.dart. It's a lot less code for the same end goal, assuming this is the right place to put it.
DebuggerDave@6d555d1

String _addMetaExtension(String filename) => '$filename.supplemental-metadata';

I found an interesting example of it's application here.

Clipped_image_20250519_000445(1).png
-> Clipped_image_20250519_000445.png.supplemental(1).json

It looks like the order of operations for the name mangling here is:
add supplemental-metadata -> remove bracket match '(1)' -> truncate to 46 chars -> add bracket match '(1)' -> add '.json'

Thus we would need to try 2 different file matching variants in the json_extractor. One without supplemental-metadata for older Google exports, and one with it for the new ones. We also need some more intelligent applications of the _shortenName function.

@DebuggerDave
Copy link

DebuggerDave commented Jul 26, 2025

This works better, till a point where a lot of videos still shows up in the date-uknown folder.

@astronyu I've found that some of my videos still get put into the "date-unknown" folder, but when I upload them to my Synology NAS they automatically get attached to a photo with a date as some sort of "live photo".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Google Photos Takeout now adds a suffix to json file (and not properly either)
6 participants