Skip to content

Instantly share code, notes, and snippets.

@gitfvb
Last active June 5, 2022 14:00
Show Gist options
  • Save gitfvb/cde8a04a159cdc265e3b to your computer and use it in GitHub Desktop.
Save gitfvb/cde8a04a159cdc265e3b to your computer and use it in GitHub Desktop.
use exiftool to move photos and videos in a subfolder structure like 2016/201612/
$exiftool = "C:\Users\Florian\Pictures\exiftool(-k).exe"
$source = "C:\Users\Florian\Pictures\k-r\DCIM1"
$destination = "C:\Users\Florian\Pictures\k-r\sorted"
$timestamp = [datetime]::UtcNow.ToString("yyyyMMddHHmmss")
$logfile = "copymedia_date$( $timestamp ).log"
<#
source: https://www.sno.phy.queensu.ca/~phil/exiftool/exiftool_pod.html
-ext only files with this extension
-o Set output file or directory name
-d Set format for date/time values
-r recursively from this directory
#>
# copy the photos to subfolders
& $exiftool -ext "jpg" -ext "DNG" -o . "-Directory<CreateDate" -d "$( $destination )\%Y\%Y%m" -r "$( $source )" -m
# copy the videos
#$exiftool -ext avi -o . '-Directory<DateTimeOriginal' -d '/volume1/photo/Devices/k-r/%Y/%Y%m' -r '/volume1/photo/Sync/k-r' > copymedia_$(date +%Y%m%d%H%M%S).log
#!/bin/sh
##################
# iPhone
##################
# copy the photos to subfolders
exiftool -o . '-Directory<CreateDate' -d '/volume1/photo/Devices/iPhone/%Y/%Y%m' -r '/volume1/photo/Sync/iPhone' > copymedia_$(date +%Y%m%d%H%M%S).log
# move the not handled files
exiftool '-Directory<DateCreated' -d '/volume1/photo/Devices/iPhone/%Y/%Y%m' -r '/volume1/Scripts/photo' > copymedia_$(date +%Y%m%d%H%M%S).log
# move the rest of the files to another directory
mkdir -p '/volume1/photo/Devices/iPhone/einsortieren/'
mv *.png '/volume1/photo/Devices/iPhone/einsortieren/'
mv *.jpg '/volume1/photo/Devices/iPhone/einsortieren/'
mv *.mov '/volume1/photo/Devices/iPhone/einsortieren/'
mv *.mp4 '/volume1/photo/Devices/iPhone_Flo/einsortieren/'
##################
# slr
##################
# copy the photos to subfolders
exiftool -ext jpg -ext DNG -o . '-Directory<CreateDate' -d '/volume1/photo/Devices/slr/%Y/%Y%m' -r '/volume1/photo/Sync/slr' > copymedia_$(date +%Y%m%d%H%M%S).log
# copy the videos
exiftool -ext avi -o . '-Directory<DateTimeOriginal' -d '/volume1/photo/Devices/k-r/%Y/%Y%m' -r '/volume1/photo/Sync/k-r' > copymedia_$(date +%Y%m%d%H%M%S).log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment