GoPro-Fotos automatisch umbenennen und kopiern
Es gibt a neichere und bessere Version do: Autosort - Schnö und einfach Bilder und Videos sortiern
Ahja, des leidige Thema "GoPro-Dateinamen". De Dateinamen schaun aus wia Kraut und Rüben, und ma kann nix zuordnen. Wos also tun?
Koa Sorg - es gibt a Lösung in Form von am Bash-Skript.
Wos tut des do? Im Prinzip prüft des Skript definierte Speicherorte auf GoPro-Videos / Kamerafotos (jo, des geht do also a für Fotografen). Wenn Dateien gfunden wurden, wird a Unterordner im Format YYYY-MM-DD erstöt, de Dateien in den Ordner kopiert noch dem Schema YYYY-MM-DD-HH-ii-ss.ext. A MP4-Video, des du am 30.01.2022 um 14:44:12 aufgnommen host, wird also do gspeichert:
/Volumes/Videos/Videos/2022-01-30/2022-01-30-14-44-12.mp4
Wenn da Kopiervorgang erfolgreich woar (wird anhand von am Hashwert gprüft), wird des Original glöscht.
Anpassn muasst nur folgende Pfade:
video_target= Dorthin wern Videos kopiertfoto_target= Dorthin wern Fotos kopiertvideo_sources= De Ordner wern noch Videos durchsuchtfoto_sources= De Ordner wern noch Fotos durchsucht
#!/bin/sh
video_target="/Volumes/Videos/Videos/"
foto_target="/Volumes/Extern01/Fotos/"
video_sources=("/Volumes/Untitled/MP_ROOT" "/Volumes/GoPro/DCIM/100GOPRO")
foto_sources=("/Volumes/Untitled/DCIM/100MSDCF" "/Volumes/Untitled/private/AVCHD/BDMV/STREAM")
# FIRST PARAMETER: 0 = KEEP FILE NAME / 1 = RENAME TO DATETIME NAME
docopy(){
num_files=`ls -1q "$1" | wc -l`
filecount=0
for file in $1/*; do
filecount=$((filecount+1))
echo "File/Folder #$filecount of $num_files"
if [[ -d ${file} ]]
then
echo "$file is Directory. Check it's subdirectories."
docopy "$file" $2 $3
fi
if [ ! -f "$file" ]; then
echo "$file does not contain any files. Next."
continue
fi
original_folder_name=`stat -f "%Sm" -t "%Y-%m-%d" "$file"`
original_file_datetime=`stat -f "%Sm" -t "%Y-%m-%d-%H-%M-%S" "$file"`
target_path="$2${original_folder_name}/"
original_file_name=$(basename ${file})
target_file="$target_path/$original_file_name"
original_file_extension="${original_file_name##*.}"
echo "Source: ${file}"
echo "Destination: ${target_path}"
echo "Copying..."
if [ -f "$file" ] && [ -f "$target_path" ];
then
md5SrcFile=$(md5 -q "$file")
md5DstFile=$(md5 -q "$target_file")
if [ "$md5SrcFile" == "$md5DstFile" ]; then
echo "The file ${target_path} already exists with MD5 Matching. Skip?"
read -p "Y to Skip, C to Continue " skip
fi
if [ "$skip" == "Y" ]; then
continue
fi
fi
mkdir -p "${target_path}"
md5SrcFile=$(md5 -q "$file")
rsync -ct ${file} ${target_path}
md5DstFile=$(md5 -q "$target_file")
if [ "$md5SrcFile" == "$md5DstFile" ] && [ "$md5SrcFile" != "" ] && [ "$md5DstFile" != "" ];
then
rm ${file}
else
echo "ERROR: MD5 MISMATCH"
exit
fi
if [ $3 -eq 1 ]
then
incrementor=0
renamed_file="$target_path$original_file_datetime.$original_file_extension"
if [ -f "$renamed_file" ]; then
incrementor=$((incrementor+1))
renamed_file="$target_path$original_file_datetime.$incrementor.$original_file_extension"
fi
mv $target_file $renamed_file
fi
echo "Done"
echo "___"
done
}
echo "Scanning default folders."
for i in "${video_sources[@]}"; do
if [ -d "$i" ] && [ -d $video_target ]; then
docopy "$i" $video_target 1
fi
done
for i in "${foto_sources[@]}"; do
if [ -d "$i" ] && [ -d $foto_target ]; then
docopy "$i" $foto_target 0
fi
done
read -p "Do you want to copy files from an individual path? Press Y or N: " tmp
if [ "$tmp" = "Y" ]; then
read -p "Enter Videos or Photos: " medium
read -p "Enter Source path: " src
if [ "$medium" == "Videos" ] && [ -d "$src" ] && [ -d $video_target ]; then
docopy "$src" $video_target 1
fi
if [ "$medium" == "Photos" ] && [ -d "$src" ] && [ -d $foto_target ]; then
docopy "$src" $foto_target 0
fi
fi
echo "Finished"