Results 1 to 5 of 5

Thread: Using find and xargs with pipes

  1. #1
    Join Date
    Sep 2006
    Beans
    3,713

    Using find and xargs with pipes

    I'm trying to convert Nikon NEF images to jpg. Usually I use find and xargs for batch processes like this for example:
    Code:
    find . -name "*.flac" -exec basename \{\} .flac \; | xargs -i ffmpeg -i \{\}.flac -acodec libvorbis -aq 3 \{\}.ogg
    However, my latest attempt is giving me no output because I can't seem to get xargs to work with pipes. An individual set of commands works:
    Code:
    dcraw -w -c MEY_7046.NEF | convert - -resize 25% MEY_7046.jpg
    exiftool -overwrite_original -TagsFromFile MEY_7046.NEF MEY_7046.jpg
    dcraw -z MEY_7046.jpg
    A nice set of commands, but not yet practical for converting a DVD with multiple directories. My truncated find-isized version does nothing:
    Code:
    find . -name "*.NEF" -exec basename \{\} .NEF \; | xargs -i dcraw -w -c \{\}.NEF | convert - -resize 25% \{\}.jpg
    Any ideas of where I'm going wrong?

  2. #2
    Join Date
    Sep 2009
    Location
    Freiburg/Germany
    Beans
    1,112
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Using find and xargs with pipes

    That pipes the output of all the dcraw runs together into one convert call.

    Try
    Code:
    find . -name "*.NEF" -exec basename \{\} .NEF \; | xargs -i sh -c 'dcraw -w -c $0.NEF | convert - -resize 25% $0.jpg' {}
    ClassicMenu Indicator - classic GNOME menu for Unity
    Unsettings - configuration program for the Unity
    Privacy Indicator - easily switch privacy settings in Unity
    Arronax - create and modify app starters

  3. #3
    Join Date
    Mar 2010
    Beans
    3

    Re: Using find and xargs with pipes

    You can skip the "dcraw -z" command by using "exiftool -tagsfromfile %d%f.NEF -all '-filemodifydate<createdate' ...".

  4. #4
    Join Date
    Sep 2006
    Beans
    3,713

    Re: Using find and xargs with pipes

    Quote Originally Posted by diesch View Post
    That pipes the output of all the dcraw runs together into one convert call.

    Try
    Code:
    find . -name "*.NEF" -exec basename \{\} .NEF \; | xargs -i sh -c 'dcraw -w -c $0.NEF | convert - -resize 25% $0.jpg' {}
    Excellent. That worked perfectly. Thanks.

    Quote Originally Posted by boardhead View Post
    You can skip the "dcraw -z" command by using "exiftool -tagsfromfile %d%f.NEF -all '-filemodifydate<createdate' ...".
    Interesting, although I decided exiftool and dcraw -z commands were unnecessary this time.

  5. #5
    Join Date
    Feb 2011
    Beans
    5

    Re: Using find and xargs with pipes

    I think what you've got here could be just what I'm looking for, but I'm really new to *nix, Ubuntu and command-line stuff so I want to check.

    If I understand correctly:

    This command searches through a directory and sub-directories, finding any files with the NEF extension and converts them to JPG (at 25% reduction).

    So does this replace the NEF files with JPGs or just add the JPGs?
    Do I need to download any repositories before running this command?

    Thanks in advance for your help.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •