1. 25

  2. 6

    I only recently discovered GNU parallel and implemented a hack-ish program that went through my FLAC library and made sure that it complied to my wishes (transcoded down to 44.1/16, added replaygain-tags etc). It took me less than an evening to fix. I really liked the string replacements which made my use case really simple.

    Part of the script, in case someone is interested:

    find /mnt/music -name "*.flac" > /tmp/all-flac-files
    cat /tmp/all-flac-files | parallel '
        if ! $(metaflac --show-sample-rate {} | grep -qi 44100); 
           echo {} >> /tmp/transcode-candidates
        if ! $(metaflac --list {}|grep -qi replaygain); then
           echo {//} >> /tmp/replaygain-folders
    cat /tmp/transcode-candidates | parallel '
        transcoded=`mktemp -d`
        if (ffmpeg -i {} -ar 44100 -sample_fmt s16 
        $transcoded/{/}) 2>/dev/null; then
           cp $transcoded/{/} {//}
           rm -rf "${transcoded}"
    cat /tmp/replaygain-folders|sort|uniq | parallel '
        pushd {}
        metaflac --add-replay-gain *.flac

    For any task like the above, GNU Parallel is just amazing! And I promise to cite if I ever write an academic article and use this tool.

    1. 4

      It’s a useful tool, but the whole parallel --citation business is a pain. Arch Linux disables this, but not Fedora (last time I checked). https://github.com/archlinux/svntogit-community/tree/packages/parallel/trunk

      1. 2

        20 may sound old but it is really quite young as GNU tools go. The moreutils version of parallel predates it but many things got rewritten (or just relicenced) in an embrace, extend, extinguish approach leaving just the GNU version. I’ve always found xargs -P to be more useful in practice because I already know how to use xargs. Or I use the normal shell & suffix and zsh specific stuff if I need to limit number of processes.