【发布时间】:2017-09-12 04:51:10
【问题描述】:
我需要在终端中对多个文件执行以下命令
SetFile -c "" -t "" <FileName>
所以我创建了一个 python 脚本,它将文件名作为参数并使用调用函数来执行命令。但我不知道如何将那些“”标记放在调用管道中。
这是代码
from subprocess import call
import sys # for sys.argv
def main():
l = len(sys.argv)
l = l - 1
if(l>0):
for i in range(l):
termExecute(sys.argv[i])
def termExecute(argument):
call(["SetFile", "-c ","","-t ","","argument"])
if __name__ == '__main__':
main()
我很确定call(["SetFile", "-c ","","-t ","","argument"]) 是错误的,我希望知道正确的写法。
编辑:
Akuls-MacBook-Pro:~ akulsanthosh$ python3 /Users/akulsanthosh/Documents/Simple/Setfile.py /Volumes/akul/Stuff/1.jpg /Volumes/akul/Stuff/2.jpg /Volumes/akul/Stuff/3.jpg
Invalid type or creator value: '""'
Invalid type or creator value: '""'
ERROR: File Not Found. (-43) on file: argument
Invalid type or creator value: '""'
Invalid type or creator value: '""'
ERROR: File Not Found. (-43) on file: argument
Invalid type or creator value: '""'
Invalid type or creator value: '""'
ERROR: File Not Found. (-43) on file: argument
【问题讨论】:
-
@bulbus 错误:找不到文件。 (-43) 在文件上:“”-t“”错误:找不到文件。 (-43) 在文件上:错误:找不到文件。 (-43) 存档:参数
-
对不起,无法在 cmets 中回答,所以将其作为答案
标签: python python-3.x subprocess