Daniel B. Thurman wrote: > It has been awhile since I have been programming in > bash or using the 'find' command and what I am trying > to do is to figure out how to run a command to decode > all my .mpc files into wav as follows: > > 1. Find all MPC files > 2. Run each file through mppdec > > I tried to do this using the 'find' command or even with a > bash script. > > Using find: > ======== > find *.mpc -type f -exec mppdec '{}' `echo {} | sed s/.mpc/.wav` \; > ** fails because you cannot use {} more than once and also exec is > mangled. > > I recalled using xargs from my past, but cannot remember how to do > it. > > find *.mpc -type f -print0 | xargs ????? > > Since I had used find/xargs in the past, I have not encountered > cases where filenames can have spaces or other characters embedded, > so this is new for me. I was not able to get around this issue with > find nor with bash scripts. Something like this perhaps: find -name '*.mpc' | while read mpc; do wav="${mpc/.mpc/.wav}" mppdec "$mpc" "$wav" done That would find all the .mpc files and loop through them line by line, reading the filename into the mp3 variable. Then a little bash substitution replace .mpc with .wav and creates a wav var. Finally, mppdec is called to decode them. I think something similar with xargs would work too: find -name '*.mpc' -print0 | \ xargs -0 -i mppdec "{}" "`echo {} | sed s/.mpc/.wav`" Neither of these are tested, so if it breaks, the pieces are yours to cherish. -- Todd OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The kind of man who wants the government to adopt and enforce his ideas is always the kind of man whose ideas are idiotic. -- H. L. Mencken
Attachment:
pgprDwZ52nPDd.pgp
Description: PGP signature
-- fedora-list mailing list fedora-list@xxxxxxxxxx To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list