如何使用快速整理照片?
这边文章主要将如何通过文件属性,比如拍摄日期,设备类型,来自动归类整理照片。
本期需要用到的工具有 exiftool ,支持全平台。
-> exiftool -g 4944107950309404_02.jpg
通常根据文件类型的不同,能看到的Exif信息也不同
---- ExifTool ----
ExifTool Version Number : 12.70
---- File ----
File Name : 4944107950309404_02.jpg
Directory : .
File Size : 2.8 MB
File Modification Date/Time : 2013:07:09 02:06:40+08:00
File Access Date/Time : 2023:11:22 13:16:36+08:00
File Inode Change Date/Time : 2023:11:22 12:21:59+08:00
File Permissions : -rwxr--r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
Image Width : 4032
Image Height : 3024
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:4:4 (1 1)
---- JFIF ----
JFIF Version : 1.01
Resolution Unit : None
X Resolution : 1
Y Resolution : 1
---- Composite ----
Image Size : 4032x3024
Megapixels : 12.2
- Date/Time Original 照片的原始时间
- Create Date 照片的创建时间
- GPSPosition GPS信息
- …
从上面的图片exif信息,可以找到拍摄日期:
-> exiftool -d "%Y/%m" "-directory<createdate" -r .
其他的图片,比如截图,APP转存的,会被剔除部分exif信息,可能没有createdate属性,那么可以根据文件的修改日期再整理一遍。
-> exiftool -d "%Y/%m" "-directory<filemodifydate" -r .
通过元素据检索文件
找出所有苹果手机拍摄的照片
-> exiftool -FileName -if '$LensId =~ /iphone/i' -r .
找出所有苹果手机拍摄的照片,并将元素据写入txt
-> exiftool -if '$LensId =~ /iphone/i' -r . > info.txt
遍历子目录,找出所有 有GPS信息的,文件扩展名是jpg的照片,并将元素据写入txt
-> exiftool -if '$GPSPosition =~ /.*/' -ext jpg -r . > info.txt
-FileName 和 -Directory是两个特殊属性,修改该属性,会变更实际文件目录和文件名。
根据元素 重命名文件。
# dryrun测试模式
-> exiftool '-testname<${FileAccessDate}' -d "IMG_%Y%m%d.%%e" original_file_name.jpg
'original_file_name.jpg' --> 'IMG_20231122.jpg'
0 image files updated
1 image files unchanged
# 这里会发生实际修改
# %%e 会自动补全文件扩展名
# %%c 会自动计数,防止重名
# -ext jpg 限定文件扩展名
# -r 递归子目录
-> exiftool '-FileName<${FileAccessDate}' -d "IMG_%Y%m%d_%%c.%%e" -ext jpg -r .
找码率20Mbps以上的视频文件
exiftool -if '${AvgBitrate#} >= 20000000' -r -ext mp4 .
留下评论