Running a python script on all the files in a directory

前端 未结 4 711
有刺的猬
有刺的猬 2020-12-19 07:45

I have a Python script that reads through a text csv file and creates a playlist file. However I can only do one at a time, like:

python playlist.py foo.csv          


        
4条回答
  •  渐次进展
    2020-12-19 08:03

    Just use a for loop with the asterisk glob, making sure you quote things appropriately for spaces in filenames

    for file in *.csv; do
       python playlist.py "$file" >> outputfile.txt;
    done
    

提交回复
热议问题