Derfor lavede jeg et script, der omdøber filerne i en mappe på en måde, så filnavn og nummerering ikke skifter med mindre filtypen også skifter.
Kode: Vælg alt
#!/bin/bash
#~ file rename made by Thomas Jensen
#~
#~ Renames files in directory with .
#~
#~ If two or more files have the same filename with different extensions, then
#~ the consecutive number will not change
#~
#~ Usage: newfn.sh <new filename>
#~
n=0
check_filename=""
for file in *; do
test -f "$file" || continue #Tester om det er en fil
filename=${file%%.*}
new_filename=$1
if [[ ${filename} == ${check_filename} ]]; then
extension=${file#*.}
number=$(printf %03d $n)
check_filename=${file%%.*}
else
extension=${file#*.}
((n++))
number=$(printf %03d $n)
check_filename=${file%%.*}
fi
# printf "\n${filename}_$(date +%Y%m%d)_${number}.$extension\n"
printf "\n${new_filename}_${number}.$extension\n"
mv $file ${new_filename}_${number}.$extension
done
printf "\n"