简体   繁体   English

将文件夹中的处理文件批处理为Python脚本参数

[英]Batch Process Files in Folder to Python Script Arguments

I'm trying to use this Python script to batch process filenames in place of the arguments. 我正在尝试使用此Python脚本代替参数来批处理进程文件名。

The script runs as follows: 该脚本运行如下:

$ python /root/vrn/raw2obj.py --volume /root/vrn/output/file-name1105.raw \
   --image /root/vrn/JPEGS/scaled/file-name1105.jpg \
   --obj /root/workfolder/output/file-name1105.obj`

The source of the script can be found here vrn/raw2obj.py . 脚本的源可以在这里找到vrn / raw2obj.py

I tried to inherit a similar structure used for batch FFmpeg processes without any luck. 我试图继承用于批处理FFmpeg进程的类似结构,但没有任何运气。 The filenames are all the same between --volume --image and --obj , it's only the extensions that vary. --volume --image--obj之间的文件名都相同,只是扩展名有所不同。

The files are numbered as well if it is easier that way to have a reg expression, it goes from file-name0000 to file-name2254 in a sequence of 1. 如果更容易使用reg表达式,则文件也将进行编号,它从file-name0000 to file-name2254的顺序为1。

Is it possible to do a search or for i in the /root/vrn/JPEGS/scaled/ folder (using linux bash only) and use the filename without extension for the arguments above using Bash? 是否可以for i in /root/vrn/JPEGS/scaled/文件夹中进行搜索或搜索for i in (仅使用linux bash),并使用Bash对上面的参数使用不带扩展名的文件名?

for i in file-name{0000..2254}; do python /root/vrn/raw2obj.py --volume /root/vrn/output/"$i".raw --image /root/vrn/JPEGS/scaled/"$i".jpg --obj /root/workfolder/output/"$i".obj done for i in file-name{0000..2254}; do python /root/vrn/raw2obj.py --volume /root/vrn/output/"$i".raw --image /root/vrn/JPEGS/scaled/"$i".jpg --obj /root/workfolder/output/"$i".obj done Worked for me. for i in file-name{0000..2254}; do python /root/vrn/raw2obj.py --volume /root/vrn/output/"$i".raw --image /root/vrn/JPEGS/scaled/"$i".jpg --obj /root/workfolder/output/"$i".obj done为我工作。 It ran through the filenames sequentially and runs the script on all of the one by one. 它依次运行文件名,并在所有文件名上一个一个地运行脚本。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM