I'm writing a python script called flac2m4a which calls ffmpeg to convert a .flac file to .m4a file. the core program is like this:
cmd = "ffmpeg -i %s -acodec alac %s.m4a" % (sys.argv[1], sys.argv[1][:-5])
os.system(cmd)
I can use the program like this:
./flac2m4a path_to_the_song.flac
But when I run it for some songs with special chars in their name:
./flac4m4a.py Justin\ Bieber\ -\ Never\ Say\ Never\ -\ The\ Remixes/01\ -\ Never\ Say\ Never\ \(feat.\ Jaden\ Smith\).flac
under linux, when I press tab to autocomplete, the special chars will be escaped with a \
, but when I read it from sys.argv[1]
, they will be converted to the normal string by Python:
Justin Bieber - Never Say Never - The Remixes/01 - Never Say Never (feat. Jaden Smith).flac
So I just want to know how to read the argv[1]
exactly as what the user input(with those \
)