How to extract string from filename solved

Tim Chase blinux.list at
Fri Jul 31 11:32:15 UTC 2015

On July 31, 2015, Tony Baechler wrote:
> You're right!  I totally missed that and I should know better.  I
> use that syntax without the "ls" all the time and I didn't even
> think about it. Maybe that's why it takes forever to run.
> Fortunately I can put "&" at the end to run it in the background.
> Of course I have thousands of files to process.

You don't want to background all thousands of processes as it will
drag your processor to its knees.  However, if your conversion
program doesn't support multiple cores internally, and you have $CORES
available, I'd recommend something like

  find /path/to/mp3s -type f -iname '*.mp3' -print0 | xargs -0 -n 1
  -P $CORES my_conversion_program --my-conversion-options

which will recursively find all *.mp3 files in /path/to/mp3s and
launch "my_conversion_program" with "--my-conversion-options" and the
filename to convert (it will do one at a time thanks to the "-n 1",
but will spawn "$CORES" proesses).

If you don't want to recurse into subdirectories, find(1) has options
to control the max-depth as well.

Instead of using $CORES, you might want to use $CORES-1 so that one
is still free for you as a user of the computer.

Hope this helps speed up jobs for you.


More information about the Blinux-list mailing list