Skip to content

Instantly share code, notes, and snippets.

@sega-yarkin
Last active February 24, 2021 02:03
Show Gist options
  • Save sega-yarkin/01f808cfb72d3e5feb8ef386429cf2b3 to your computer and use it in GitHub Desktop.
Save sega-yarkin/01f808cfb72d3e5feb8ef386429cf2b3 to your computer and use it in GitHub Desktop.
# Set EXIF timestamp based on filename
exiftool -d '%m-%d-%y_%H%M%S0.jpg' -overwrite_original '-DateTimeOriginal<Filename' -ext jpg .
exiftool -d '%m-%d-%y_%H%M%S0.jpg' -overwrite_original '-DateTimeOriginal<Filename' -if 'not $DateTimeOriginal' -ext jpg .
# Set EXIF User Comment to original filename
exiftool -overwrite_original '-UserComment<${Filename;s/\.[^.]*$//}' -ext jpg .
# Copy EXIF
exiftool -overwrite_original -TagsFromFile "$from" "$to"
# Set EXIF timestamp from file mtime
exiftool -overwrite_original '-DateTimeOriginal<FileModifyDate' -ext jpg .
# Shift dates in EXIF (-AllDates[+-]=Y:m:D HH:MM:SS)
exiftool -overwrite_original '-AllDates+=1:5:1 16:00:00' -ext jpg .
# Touch file with EXIF timestamp
exiftool '-FileModifyDate<DateTimeOriginal' -ext jpg .
# Touch file with timestamp parsed from filename
exiftool -d '%Y%m%d_%H%M%S' '-FileModifyDate<${Filename;s/(.*)(\d{8}_\d{6})\.[^.]*$/$2/}' -ext jpg .
# Rename files to lower case
exiftool '-Filename<${Filename;$_=lc($_)}' -ext jpg .
# File extension to lower case
exiftool '-Filename<${Filename;s/\.[^.]*$//}.%le' -ext jpg .
# Rename file and use only EXIF timestamp
exiftool -d '%Y%m%d_%H%M%S' '-Filename<${DateTimeOriginal}.%le' -ext jpg .
# Add timestamp suffix to file
exiftool -d '%Y%m%d_%H%M%S' '-Filename<%f_${DateTimeOriginal}.%le' -ext jpg .
# Rename based on User Comment and EXIF timestamp
exiftool -d '%Y%m%d_%H%M%S' '-Filename<${UserComment}_${DateTimeOriginal}.%le' -ext jpg .
# Rename based on file mtime
exiftool -d '%Y%m%d_%H%M%S' '-Filename<%f_${FileModifyDate}.%le' -ext jpg .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment