Running a python script on all the files in a directory

前端 未结 4 697
有刺的猬
有刺的猬 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:13

    for f in *.csv; do
      python playlist.py "$f" "${f%.csv}list.txt"
    done
    

    Will that do the trick? This will put foo.csv in foolist.txt and abc.csv in abclist.txt.

    Or do you want them all in the same file?

提交回复
热议问题