我从一个丢失的分区中恢复了图像,现在需要按照每张图片EXIF数据中的创建日期对它们进行排序或放入文件夹中。
我已经安装了digiKam和shotwell,但是在任何选项中都没有找到实现这一功能的方法。
请问有人能告诉我如何使用这两个程序或者其他任何方法来完成这个任务吗?
我已经安装了digiKam和shotwell,但是在任何选项中都没有找到实现这一功能的方法。
请问有人能告诉我如何使用这两个程序或者其他任何方法来完成这个任务吗?
apt-get install jhead
)jhead -ft *
。这将使用exif元数据的创建日期在文件系统中设置文件日期。sudo apt install exiftool
exiftool '-filename<CreateDate' -d %Y%m%d%%-.4nc.%%le -r
image.jpg
移动到以其创建日期命名的目录中,日期格式为'YYYY-MM-DD'。exiftool -d %Y-%m-%d "-directory<datetimeoriginal" image.jpg
cd /home/me/Pictures/staging
,然后再调用exiftool。 - Scottexiftool '-filename<CreateDate' -d %Y%m%d%H%M%S%-.4nc.%%le -r
命令可以提取照片的拍摄时间,并按照年月日时分秒的格式重命名文件。 - chloesoe#! /bin/bash
shopt -s globstar || exit
for PIC in **
do
# look only for jpg
if [[ "$PIC" =~ \.JPG$ ]] || [[ "$PIC" =~ \.jpg$ ]]; then
# ignore jpg that have 8 numbers at beginning followed by _ or after IMG_ or P_ and followed by _ (already date stamped)
if [[ "$PIC" =~ [[:digit:]]{8}_.*$ ]] || [[ "$PIC" =~ IMG_[[:digit:]]{8}_.*$] ]] || [[ "$PIC" =~ P_[[:digit:]]{8}_.*$] ]]; then
:
else
# get the date and time from the tag
DATE=$(exiftool -p '$DateTimeOriginal' "$PIC" | sed 's/[: ]//g')
echo "file_$PIC"
# customize date, in this case eliminate the time, getting only the date in 8 numbers and adding _
DATEMOD2=$(echo $DATE | sed -e 's/^\(.\{8\}\).*/\1_/')
echo "datemod2_$DATEMOD2"
# check if DateTimeOriginal was present
if [[ "$PIC" == "$DATEMOD2$PIC" ]];then
# as DateTimeOriginal is not present try with HistoryWhen
DATE=$(exiftool -p '$HistoryWhen' "$PIC" | sed 's/[: ]//g')
DATEMOD2B=$(echo $DATE | sed -e 's/^\(.\{8\}\).*/\1_/')
echo "datemod2B_$DATEMOD2B"
# check if HistoryWhen is present
if [[ "$PIC" == "$DATEMOD2B$PIC" ]];then
# nor the tag DateTimeOriginal, nor HistoryWhen present
echo "skip"
else
# this will be done
echo "mv -i "$PIC" $(dirname "$PIC")/"$DATEMOD2B""$PIC""
#uncomment if you like it
#mv -i "$PIC" $(dirname "$PIC")/"$DATEMOD2B""$PIC"
fi
else
# this will be done
echo "mv -i "$PIC" $(dirname "$PIC")/"$DATEMOD2""$PIC""
#uncomment if you like it
#mv -i "$PIC" $(dirname "$PIC")/"$DATEMOD2""$PIC"
fi
fi
fi
done
#! /bin/bash
shopt -s globstar || exit
for PIC in **
do
# look only for jpg
if [[ "$PIC" =~ \.JPG$ ]] || [[ "$PIC" =~ \.jpg$ ]]; then
echo "file_$PIC"
# get the date and time from the tag DateTimeOriginal
DATE=$(exiftool -p '$DateTimeOriginal' "$PIC" | sed 's/[: ]//g')
LONGDATE=$(echo $DATE | sed -e 's/^\(.\{12\}\).*/\1/')
# check if DateTimeOriginal is 0000... OR empty
if [[ "$LONGDATE" != "000000000000" ]] && [[ -n "$LONGDATE" ]]; then
echo "datetimeoriginal_$LONGDATE"
# modify the attribute date with the info in the tag date
touch -t $LONGDATE "$PIC"
# customize date, in this case eliminate the time, getting only the date in 8 numbers and adding _
DATEMOD2=$(echo $DATE | sed -e 's/^\(.\{8\}\).*/\1_/')
echo "datemod2_$DATEMOD2"
# skip renaming if
# 8 numbers at beginning followed by _ or after IMG_ or P_ and followed by _ (already date stamped)
if [[ "$PIC" =~ [[:digit:]]{8}_.*$ ]] || [[ "$PIC" =~ IMG_[[:digit:]]{8}_.*$] ]] || [[ "$PIC" =~ P_[[:digit:]]{8}_.*$] ]]; then
:
else
# this will be done
filename=$(basename "$PIC")
echo "$filename"
echo "mv -i \""$PIC"\" \""$(dirname "$PIC")"/"$DATEMOD2""$filename"\""
#uncomment if you like it
mv -i "$PIC" "$(dirname "$PIC")/$DATEMOD2$filename"
fi
else
# get the date and time from the tag HistoryWhen
DATE=$(exiftool -p '$HistoryWhen' "$PIC" | sed 's/[: ]//g')
LONGDATE=$(echo $DATE | sed -e 's/^\(.\{12\}\).*/\1/')
# check if Historywhen is 0000... or empty
if [[ "$LONGDATE" != "000000000000" ]] && [[ -n "$LONGDATE" ]]; then
echo "historywhentag_$LONGDATE"
touch -t $LONGDATE "$PIC"
DATEMOD2B=$(echo $DATE | sed -e 's/^\(.\{8\}\).*/\1_/')
echo "datemod2B_$DATEMOD2B"
if [[ "$PIC" =~ [[:digit:]]{8}_.*$ ]] || [[ "$PIC" =~ IMG_[[:digit:]]{8}_.*$] ]] || [[ "$PIC" =~ P_[[:digit:]]{8}_.*$] ]]; then
:
else
# this will be done
filename=$(basename "$PIC")
echo "$filename"
echo "mv -i \""$PIC"\" \""$(dirname "$PIC")"/"$DATEMOD2B""$filename"\""
#uncomment if you like it
mv -i "$PIC" "$(dirname "$PIC")/$DATEMOD2B$filename"
fi
else
# get the date and time from the tag tag filemodifydate
DATE=$(exiftool -p '$filemodifydate' "$PIC" | sed 's/[: ]//g')
LONGDATE=$(echo $DATE | sed -e 's/^\(.\{12\}\).*/\1/')
# check if filemodifydate is 0000... or empty
if [[ "$LONGDATE" != "000000000000" ]] && [[ -n "$LONGDATE" ]]; then
#echo "filemodifydatetag_$LONGDATE"
#touch -t $LONGDATE "$PIC"
DATEMOD2C=$(echo $DATE | sed -e 's/^\(.\{8\}\).*/\1_/')
echo "datemod2C_$DATEMOD2C"
if [[ "$PIC" =~ [[:digit:]]{8}_.*$ ]] || [[ "$PIC" =~ IMG_[[:digit:]]{8}_.*$] ]] || [[ "$PIC" =~ P_[[:digit:]]{8}_.*$] ]]; then
:
else
# this will be done
filename=$(basename "$PIC")
echo "$filename"
echo "mv -i \""$PIC"\" \""$(dirname "$PIC")"/"$DATEMOD2C""$filename"\""
#uncomment if you like it
mv -i "$PIC" "$(dirname "$PIC")/$DATEMOD2C$filename"
fi
else
echo "Error, NO date available"
fi
fi
fi
fi
done
exiftool "-Directory<DateTimeOriginal" -d "%Y%m" *
jhead -n%Y/%m/%d/%Y%m%d%H%M /Destination/*.jpg
它会将当前目录中的所有JPG文件按照年/月/日/年月日时分的格式进行排序、移动和重命名,生成一个漂亮的目录结构和唯一的文件名。jhead -n%Y/%m/%d/%Y-%m-%d--%H%M-- *.jpg
- Vedavrat现在有一个名为nautilus-columns的扩展,它可以添加EXIF数据以及MP3(ID3),PDF和其他元数据。这些新列也可以用作排序来源。
安装方法如下:
sudo add-apt-repository ppa:atareao/nautilus-extensions sudo apt update sudo apt install nautilus-columns