dsuurlant / takeout-redate
A Symfony Console CLI tool to restore filesystem timestamps for Google Takeout media from JSON metadata.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:project
pkg:composer/dsuurlant/takeout-redate
Requires
- php: ^8.4
- symfony/console: ^7.3
- symfony/process: ^7.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.89
- humbug/box: ^4.6
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.5
README
A Symfony Console application to recursively go through your Google Photos Takeout archive and rewrite the file dates according to the accompanying metadata json.
Requirements
- PHP 8.4 or higher
Recommended Usage with Google Photos Takeout
When exporting your Google Photos archive, the ZIP files strip the original creation and modification dates from your photos and videos. However, these dates are preserved in the accompanying JSON metadata files. This tool restores those dates programmatically.
Overview
The process involves three main steps:
- Obtain and extract your Google Photos Takeout archive
- Consolidate all files into a single directory structure
- Restore dates using this tool
Step 1: Obtain Your Archive
- Request your Google Photos archive from Google Takeout
- Download all ZIP files before they expire (archives have expiration dates)
- Choose a storage location:
- Recommended: Local device or NAS for faster processing
- Not recommended: Directly to another cloud service (too slow)
Important: If you do not download the entire archive before expiration, a newly requested Takeout archive will not have the same file distribution across different ZIPs, resulting in potential data loss. Make sure to download your entire archive before the expiration date.
Step 2: Extract and Consolidate
-
Extract all ZIP files from your download
-
Consolidate the extracted directories.
On macOS: If files are split into multiple "Takeout 1", "Takeout 2", etc. directories, use this script to merge them:
#!/bin/bash for src in Takeout\ [0-9]*; do [ -d "$src" ] || continue rsync -a --info=progress2 --ignore-existing --remove-source-files "$src"/ "Takeout"/ && find "$src" -type d -empty -delete done
On other platforms: Files may automatically merge into a single directory, or you can manually combine them.
Note: Google may distribute metadata JSON files across different ZIP archives, meaning a photo's metadata might not be in the same archive as the photo itself. You must have the entire archive extracted and consolidated before running the date restoration tool.
Step 3: Restore Dates
Google exports photos organized by year:
./Photos from 2018/
./Photos from 2019/
./Photos from 2020/
./Photos from 2021/
...
Recommended approach: Process one year at a time to avoid timeouts with large archives.
For each year directory:
- Set your base directory (optional, for convenience):
export TAKEOUT_DIR="/mystorage/takeout/photos/"
- Test with dry-run first:
php takeout-redate.phar --path="$TAKEOUT_DIR/Photos from 2018" --dry-run
- If no errors, run for real and optionally delete metadata files after processing:
php takeout-redate.phar --path="$TAKEOUT_DIR/Photos from 2018" --delete
- Repeat for each year directory in your archive
Happy archiving and good luck moving away from Google!
Installation
As PHAR
Download the compiled PHAR file and make it executable:
chmod +x takeout-redate.phar mv takeout-redate.phar /usr/local/bin/takeout-redate
Or use it directly:
php takeout-redate.phar
Usage
# Run the application php bin/app # Or after building the PHAR ./takeout-redate.phar
Development
# Install dependencies composer install # Run tests composer test # Build PHAR file composer build # Test build locally (runs tests, builds PHAR, and verifies it works) composer test-build # Code quality checks composer quality
License
MIT