>Won't that write the mp3 to the current working dir? (Is that the dir where
>the .py lives? Or even the Python bin dir? Perhaps >the cwd parameter of
>call() will be good?
Yeah, it just wrote the mp3's to my desktop, where I had the .py
script. But that was fine for my purposes. Just for curios
--
On Fri, Aug 1, 2014 12:35 AM CEST Steven D'Aprano wrote:
>You may have already have solved your problem, unfortunately my
>emails are coming in slowly and out of order, but I have a suggestion:
>
>On Thu, Jul 31, 2014 at 03:53:48PM -0400, C Smith wrote:
>> I am o
>However, the subprocess call above uses a list for the command, and that form
>DOES NOT pass anything to the shell. The >command gets executed directly. And
>therefore no spaces need escaping at all.
That makes more sense to me now.
In terms of the code review, I found that stackexchange has a
Peter Otten <__pete...@web.de> writes:
> C Smith wrote:
>
> > Nice, these are useful tools. I have been building something with
> > just basic stuff and avoiding learning any libraries. If I wanted to
> > get some insight on a larger program that is about 1000 lines, would
> > that be doable here?
C Smith wrote:
> Nice, these are useful tools. I have been building something with just
> basic stuff and avoiding learning any libraries. If I wanted to get
> some insight on a larger program that is about 1000 lines, would that
> be doable here?
In general we prefer concrete questions and small
On 01Aug2014 08:35, Steven D'Aprano wrote:
[...]
I want to use Python to call ffmpeg to convert each file to an .mp3.
So far this is what I was trying to use:
import os, subprocess
track = 1
for filename in os.listdir('myDir'):
subprocess.call(['ffmpeg', '-i', filename, str(track)+'.mp3'])
Nice, these are useful tools. I have been building something with just
basic stuff and avoiding learning any libraries. If I wanted to get
some insight on a larger program that is about 1000 lines, would that
be doable here?
On Thu, Jul 31, 2014 at 7:37 PM, Peter Otten <__pete...@web.de> wrote:
>
C Smith wrote:
I'd throw in a check to verify that filename is indeed a flac:
> or more accurately
> import os, subprocess, re
> directory = '/abs/path'
> for track, filename in enumerate(os.listdir(directory), 1):
> pathname = os.path.join(directory, filename)
if filename.endswith(".fl
or more accurately
import os, subprocess, re
directory = '/abs/path'
for track, filename in enumerate(os.listdir(directory), 1):
pathname = os.path.join(directory, filename)
subprocess.call(['ffmpeg', '-i', pathname, filename[:-5]+'.mp3'])
On Thu, Jul 31, 2014 at 7:13 PM, C Smith wrote:
>
thanks, got it
import os, subprocess, re
directory = 'abs/path'
for track, filename in enumerate(os.listdir(directory), 1):
pathname = os.path.join(directory, filename)
subprocess.call(['ffmpeg', '-i', pathname, filename+str(track)+'.mp3'])
On Thu, Jul 31, 2014 at 7:02 PM, C Smith wrote:
Huh, that is quite an annoyance about changing the order though. Any
ideas about that? I will look into it further in the meantime...
On Thu, Jul 31, 2014 at 6:57 PM, C Smith wrote:
> Works now, thanks!
>
> On Thu, Jul 31, 2014 at 6:57 PM, C Smith wrote:
>> woops, I see it pathname != filename
>
Works now, thanks!
On Thu, Jul 31, 2014 at 6:57 PM, C Smith wrote:
> woops, I see it pathname != filename
>
> On Thu, Jul 31, 2014 at 6:55 PM, C Smith wrote:
>>>for track, filename in enumerate(os.listdir(directory), 1):
>> It seems kinda counter-intuitive to have track then filename as
>> varia
woops, I see it pathname != filename
On Thu, Jul 31, 2014 at 6:55 PM, C Smith wrote:
>>for track, filename in enumerate(os.listdir(directory), 1):
> It seems kinda counter-intuitive to have track then filename as
> variables, but enumerate looks like it gets passed the filename then
> track numbe
>for track, filename in enumerate(os.listdir(directory), 1):
It seems kinda counter-intuitive to have track then filename as
variables, but enumerate looks like it gets passed the filename then
track number. Is that correct and just the way enumerate works, a
typo, or am I missing something else he
Oops, a silly bug:
On Fri, Aug 01, 2014 at 08:35:34AM +1000, Steven D'Aprano wrote:
> directory = '/path/to/the/directory'
> for track, filename in enumerate(os.listdir(directory), 1):
> pathname = os.path.join(directory, filename)
> subprocess.call(['ffmpeg', '-i', filename, str(track)+'
You may have already have solved your problem, unfortunately my
emails are coming in slowly and out of order, but I have a suggestion:
On Thu, Jul 31, 2014 at 03:53:48PM -0400, C Smith wrote:
> I am on OSX, which needs to escape spaces in filenames with a backslash.
Same as any other Unix, or Li
Actually, I can get re.sub() to print the filenames where they look
like they would be in the correct format for the shell, like this:
10\ track \number \ten.flac
but the shell still says that no such file exists, and I am sure I am
operating on them in the right place because I can modify them. So
Okay I messed up with slash instead of backslash, so the re.sub()
works, but I am still curious about the previous question.
On Thu, Jul 31, 2014 at 6:14 PM, C Smith wrote:
> Even when I am using:
> re.sub('/s', '\\/s', filename)
> I am still getting the same output, even trying to assign the abo
Even when I am using:
re.sub('/s', '\\/s', filename)
I am still getting the same output, even trying to assign the above to
a new variable doesn't work (as I wasn't sure if re.sub returned a new
value or changed filename in place, I tried both with)
Does the Python interpreter strip off backslashes
>Change:
>subprocess.call(['ffmpeg', '-i', filename, str(track)+'.mp3'])
>to:
>subprocess.call(['ffmpeg', '-i', '"%s"' % filename, str(track)+'.mp3'])
I still get the same errors, the filenames are passed to the shell
without escaping the spaces.
>Why not using ffmpeg without jumping into Pyt
On 7/31/2014 12:53 PM, C Smith wrote:
I am on OSX, which needs to escape spaces in filenames with a backslash.
There are multiple files within one directory that all have the same
structure, one or more characters with zero or more spaces in the
filename, like this:
3 Song Title XYZ.flac.
I want
I am on OSX, which needs to escape spaces in filenames with a backslash.
There are multiple files within one directory that all have the same
structure, one or more characters with zero or more spaces in the
filename, like this:
3 Song Title XYZ.flac.
I want to use Python to call ffmpeg to convert
22 matches
Mail list logo