如何使用exiftool移除文件夹图片元数据并保留拍摄日期?
Absolutely, ExifTool handles this kind of targeted metadata removal perfectly—let’s walk through exactly how to set this up for your folder of images.
Core Command to Keep Shooting Date & Delete All Other Metadata
The key trick is using -all= to wipe all metadata, then explicitly excluding the date tags you want to keep with the -- prefix (this tells ExifTool to skip deleting those specific tags).
Here’s the base command for a folder (it works recursively, so it hits subfolders too):
exiftool -r -all= --DateTimeOriginal --CreateDate --ModifyDate /path/to/your/image/folder
Breakdown of Each Parameter:
-r: Recursively process all images in subfolders under your target directory-all=: Delete every piece of metadata attached to the images--DateTimeOriginal: Keep the original shooting date (this is the primary EXIF tag for when the photo was captured)--CreateDate: Retain the file’s creation date (useful for maintaining consistent file timelines)--ModifyDate: Preserve the file’s last modified date (optional but recommended for keeping file system consistency)
Adding Custom Exception Rules
If you ever need to keep other metadata tags down the line (e.g., camera make/model, specific GPS data), simply add more --[Tag Name] parameters. For example, to keep camera info alongside dates:
exiftool -r -all= --DateTimeOriginal --CreateDate --ModifyDate --Make --Model /path/to/your/image/folder
Target Specific Image Formats
If you only want to process certain file types (e.g., JPG, PNG, RAW), add the -ext flag for each format:
exiftool -r -ext jpg -ext png -ext cr2 -all= --DateTimeOriginal --CreateDate --ModifyDate /path/to/your/image/folder
Important Notes
- Backups: ExifTool automatically creates backup files (e.g.,
photo.jpg_original) by default. Once you verify the metadata removal worked as expected, you can delete all backups with:exiftool -delete_original /path/to/your/image/folder - Test First: Always test the command on a single image before running it on your entire folder. For example:
Then runexiftool -all= --DateTimeOriginal test-image.jpgexiftool test-image.jpgto confirm only the date tags remain. - RAW Files: Some RAW formats (like CR2, NEF) might have additional date-related tags, but
DateTimeOriginalis universally supported across most image types.
内容的提问来源于stack exchange,提问作者s3voch7

