1

I found myself doing a repetitive task and wondered how I can automate it.

I can write a function script with python(3), to iterate through each item in a folder, but I'm not sure how I would run that through command prompt.

enter image description here

I have sort of looked into how it would be possible, but I think a direct response to my exact question would be more helpful and easier to grasp.

My question comes more from a desire to learn than it does from laziness!

TheJack
  • 111
  • 1
  • 8

1 Answers1

3

You could use os.system, but subprocess.run is probably better. You should also use glob:

import glob
import subprocess

files = glob.glob('*.wav')

for file in files:
    subprocess.run(['xWMAEncode', file, file.replace('.wav', '.xwm')])
iz_
  • 15,923
  • 3
  • 25
  • 40