如何找到特定的元数据内容并从图片中删除?

时间:2016-08-31 10:59:10

标签: windows command-line exif exiftool

我尝试在exiftool.exe的帮助下在我的* .jpg文件中找到特定的元数据内容,如“Odeon”,然后从文件中删除此特定标记。

我无法使用命令

找到“Odeon”
exiftool -if "$keywords =~ /Odeon/" .

我知道它就在那里,对于这个例子,内容存储在“位置”标签中。

请有人告诉我,怎么办 a)找到内容,无论它存储在* .jpg中 b)从这个文件中删除这个找到的标签(没有备份文件)?

1 个答案:

答案 0 :(得分:1)

The reason that your command doesn't work is because you're only checking the Keywords tag. Location is a different tag and you would have check there for that info.

Unfortunately, Exiftool doesn't have the ability to list only the tags that have matching data. You can pipe the output through another command line program like Find (since you're on Windows) or Grep (other platforms). In that case, your command line would look like this:
exiftool -g1 -a -s FileOrDir | Find "Odeon"
That would list all the tags that have your info.

After you found the tag, you could then remove it without having a backup file with this command, replacing TAG with the name of the tag:
exiftool -overwrite_original -TAG= FileOrDir
Take note that this command would remove that tag from all the files if you specify a dir. If you want to be more selective and the tag contains ONLY the text "Odeon", then you could use this command. Note that this command is case sensitive. It would not remove "oDeON" or other variations:
exiftool -overwrite_original -TAG-="Odeon" FileOrDir
If you wanted to remove a certain tag that contains "Odeon" as part of a longer string and be case insensitive, then you could add the -if option.
exiftool -overwrite_original -if "$TAG=~/odeon/i" -TAG= FileOrDir

Finally, there is the shotgun approach using the -api "Filter=…" option. This requires version 10.05 or greater. This command:
exiftool -overwrite_original -api "Filter=s/odeon//gi" -tagsfromfile @ -all:all FileOrDir
would remove "odeon" (case insensitive) from all tags in the file. It would not remove the tag and if odeon was part of a longer string, the rest of the string would remain. For example, if Location was equal to "Odeon", it would become a blank string. If Description was "This is Odeon", it would become "This is ". The part after "Filter=" is a perl regex substitution and you could further refine it by looking into regex.