Skip to content

Commit

Permalink
Merge pull request #369 from r41d/noExtension
Browse files Browse the repository at this point in the history
Handle edge case where image file was uploaded without an extension
  • Loading branch information
TheLastGimbus authored Jan 29, 2025
2 parents 6776520 + 49ea752 commit a9de187
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ What if you want to just have one folder with all photos, in chronological order

This script does just that - it organizes and cleans up your Takeout for you 🧹😌

It will take all of those folders, find all photos in them, set their and `file last modified` correctly, and put it in one big folder (or folders divided by a month) 🗄
It will take all of those folders, find all photos in them, set their `file last modified` correctly, and put it in one big folder (or folders divided by a month) 🗄

## How to use:
Since `v3.2.0`, `gpth` is interactive 🎉 - you don't need to type any complicated arguments - just get your takeout, run gpth, and follow prompted instructions 💃
Expand Down
8 changes: 8 additions & 0 deletions lib/date_extractors/json_extractor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Future<File?> _jsonForFile(File file, {required bool tryhard}) async {
// test: combining this with _shortenName?? which way around?
_bracketSwap,
_removeExtra,
_noExtension,
// use those two only with tryhard
// look at https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/issues/175
// thanks @denouche for reporting this!
Expand All @@ -54,6 +55,13 @@ Future<File?> _jsonForFile(File file, {required bool tryhard}) async {
return null;
}

// if the originally file was uploaded without an extension,
// (for example, "20030616" (jpg but without ext))
// it's json won't have the extension ("20030616.json"), but the image
// itself (after google proccessed it) - will ("20030616.jpg" tadam)
String _noExtension(String filename) =>
p.basenameWithoutExtension(File(filename).path);

String _removeDigit(String filename) =>
filename.replaceAll(RegExp(r'\(\d\)\.'), '.');

Expand Down
2 changes: 1 addition & 1 deletion lib/grouping.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension Group on Iterable<Media> {

/// Removes duplicate media from list of media
///
/// This is ment to be used *early*, and it's aware of un-merged albums.
/// This is meant to be used *early*, and it's aware of un-merged albums.
/// Meaning, it will leave duplicated files if they have different
/// [Media.albums] value
///
Expand Down

0 comments on commit a9de187

Please sign in to comment.