简体   繁体   English

如何使用由 Python 中的子进程调用的 Exiftool 添加标志以仅搜索某个标签

[英]How can I add flags to just search for a certain tag using Exiftool called by a subprocess within Python

I have some code that lists all the files in a directory and then calls a subprocess to use Exiftool to see the metadata for the images.我有一些代码列出目录中的所有文件,然后调用子进程以使用 Exiftool 查看图像的元数据。 I want to be able to add a flag to see just one specific tag.我希望能够添加一个标志以仅查看一个特定标签。 How can I do this.我怎样才能做到这一点。 The flag is -Route.标志是-Route。 Is it also possible to alert me if a tag isn't a specific value, for example if its meant to be 3 or 4 and it was a 2.如果标签不是特定值,是否也可以提醒我,例如,如果它是 3 或 4 而它是 2。

My code is.我的代码是。

import os
import subprocess
import sys
filesPath = 'folder to search'
for root, dirs, files in os.walk(filesPath):
    for name in files:
        print("echo", os.path.join(root, name))
        subprocess.call(["exiftool", os.path.join(root, name)])

I have since solved this issue when it comes to adding the flag.从那以后,我在添加标志时解决了这个问题。 It needs to be done as a separate part of the argument.它需要作为论证的一个单独部分来完成。

import os
import subprocess
import sys
filesPath = 'folder to search'
for root, dirs, files in os.walk(filesPath):
    for name in files:
        print("echo", os.path.join(root, name))
        subprocess.call(['exiftool', '-Route', os.path.join(root, name)])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Selenium Webdriver(Python)验证另一个HTML标签中是否存在某个HTML标签? - How can I verify the presence of a certain HTML tag within another HTML tag using Selenium Webdriver (Python)? 如何使用python读取带有相应标志的多个文件,以便可以在它们中搜索特定的字符串? - How do I read in multiple files with corresponding flags using python so that I can search them for specific strings? 如何使用ElementTree在xml文件中搜索标签,其中我有一个具有特定值的特定“父”标签? (蟒蛇) - How do I search for a Tag in xml file using ElementTree where i have a certain “Parent”tag with a specific value? (python) 如何在python的子过程调用中添加参数字典? - How can I add a dictionary of parameters into a subprocess call in python? 在Python(Ubuntu)中使用exiftool和XMPtool解码某些图片的IrradianceList标签 - Decode IrradianceList tag for some pictures using exiftool and XMPtool in Python (Ubuntu) 如果不使用子进程,如何使用python读取stderr? - How can I read stderr with python if I'm NOT using subprocess? 我如何使用子进程在 python tkinter 中传递文件名 - how can i pass a file name in python tkinter using subprocess 如何使用Python子进程发送“复制”命令 - How Can I Send a “Copy” Command Using Python Subprocess 如何从 Python 作为与 Python session 平行的子进程启动 Tensorboard 开发? - How can I start Tensorboard dev from within Python as a subprocess parallel to the Python session? 如何从某行开始使用stdin文件创建python子进程? - How do I create a python subprocess using a file for stdin starting at a certain line?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM