have python output filepath for terminal
noobie StackOverflow poster here!
i have written a simple python script which will scan through a folder and
convert the sample rates of audio files using the SoX command line tool
(http://sox.sourceforge.net/Main/HomePage).
the problem is, if the folder or the file has a SPACE in it, the terminal
won't recognize the path. in order to solve this, i need to replace any
SPACE with a "\ "
does anyone know of an easy way to do this? the script works perfectly
otherwise!thanks in advance.
import fnmatch
import os
rootPath = '/Volumes/HDD/ianks/Desktop/Pairadimez2/'
pattern = '*.wav'
sampleRate = "88200"
for root, dirs, files in os.walk(rootPath):
for filename in fnmatch.filter(files, pattern):
print( "Processing .... " + filename)
os.system("sox -G %s --clobber %s rate -v -s %s" %
(os.path.join(root, filename), os.path.join(root, filename),
sampleRate))
No comments:
Post a Comment