This is driving me crazy.
I have a bunch of mp3 that I want to transcode using ffmpeg
.
I'm trying to use this one-liner (the script is bigger, this is the problematic section):
find . -type f \( -iname \*.mp3 \) | parallel ffmpeg -i "{}" -acodec libmp3lame -ab 128k "$output_folder_with_spaces/{.}-128k.mp3" \;
(The iname
section is there because in the future more extensions will maybe be used)
But even using the quotes in {}
, I always get No such file or directory
, cause the mp3 is named 01 - My song
. And I don't know if "$output_folder_with_spaces"
is going to work either.
I've googled a lot, but can't find this example: using {}
from find
that {}
has spaces. I've only found when using a variable or hardcoded paths in quotes.
Anyone knows how I can solve this space problem, in this scenario?
Best Answer
You are using the wrong replacement string with
parallel
; you'll also need-q
to pass quoted arguments and I'm not sure what the trailing\;
does...Example:
(note the trailing
/
in the path assigned todirname_with_spaces
) and somemp3
file names with spaces under atest
directory, right undercwd
:using
produces the following files:
Note the command line
q
uoting (parallel -q
) and the usage of:which means the path from
find
output e.g../test/Mouret - Rondeau.mp3
and
which expands to
Mouret - Rondeau
and then"$dirname_with_spaces"{/.}
expands to/home/don/my dir with spaces/Mouret - Rondeau
The latter is quite different from the
{.}
used in your commandwhich would expand to
./test/Mouret - Rondeau
and then"$dirname_with_spaces"{.}
would expand to/home/don/my dir with spaces/./test/Mouret - Rondeau
. Obviously, this will error out as there is no/./test/
under/home/don/my dir with spaces
.