first commit
This commit is contained in:
commit
9c4cd95d78
2 changed files with 72 additions and 0 deletions
15
README.md
Normal file
15
README.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
Simple script to rename multimediafiles to the shotdate.
|
||||||
|
|
||||||
|
You need to install "exiftool" on your computer!
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
./name2timestamp /path/to/dir/with/files/
|
||||||
|
|
||||||
|
Config:
|
||||||
|
|
||||||
|
Please change the Variable "ending" to your needs.
|
||||||
|
for example: ending=MTS to ending=jpg
|
||||||
|
|
||||||
|
|
||||||
|
This scipt should rename every file "exiftool" can work with...
|
57
name2timestamp
Executable file
57
name2timestamp
Executable file
|
@ -0,0 +1,57 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
## Variables
|
||||||
|
#
|
||||||
|
|
||||||
|
# Dir of files
|
||||||
|
dir="$2"
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
## Main
|
||||||
|
#
|
||||||
|
printhelp() {
|
||||||
|
echo "****
|
||||||
|
You need to install 'exiftool' on your computer!
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
./name2timestamp 'fileending' /path/to/dir/with/files/
|
||||||
|
|
||||||
|
For 'fileending' you can set everything exiftool can handle with, like 'jpeg' or 'MTS'.
|
||||||
|
(And this script can find it in the given dir... :o))
|
||||||
|
****
|
||||||
|
"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
convertfile() {
|
||||||
|
|
||||||
|
# Check for exiftool
|
||||||
|
|
||||||
|
if ! [ -x "$(command -v exiftool)" ]; then
|
||||||
|
echo 'Error: exiftool is not installed. Please install exiftool to use this script!' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Rename file
|
||||||
|
|
||||||
|
for file in "$dir"/*."$ending"
|
||||||
|
do
|
||||||
|
# Getting new name for file
|
||||||
|
shottime=`exiftool -"DateTimeOriginal" -fast -R -d "%Y-%m-%d %H:%M:%S%z" -s -S "$file"`
|
||||||
|
newname=`date -d "$shottime" "+%Y%m%d_%H%M%S"`
|
||||||
|
# Rename file
|
||||||
|
mv "$file" "$dir"/"$newname"."$ending"
|
||||||
|
echo "renamed "$file" to "$newname"."$ending""
|
||||||
|
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#Print help if $1 is "--help" otherwise set it to fileending and start converting
|
||||||
|
if [[ "$1" = "--help" ]]; then printhelp; else ending="$1" && convertfile; fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue