Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using a wonderful program called ExifTool to recursively rename a large batch of files.

Here is example usage:

$ exiftool -r -ext JPG '-FileName<CreateDate' -d %Y%m%d_%H%M%S.jpg .
Error: './folder1/110310_135433.jpg' already exists - ./folder1/source.jpg
Warning: No writable tags found - ./folder2/110404_095111.jpg
   68 directories scanned
 1650 image files updated
    5 image files unchanged
    2 files weren't updated due to errors

When processing very large batches of images, the number of files not updated due to errors is often in the hundreds, therefore moving each file individually with mv is out of the question.

I'd like to simultaneously move the files with errors/warnings to a separate directory for further processing.

I need to extract the paths of the problem files from the terminal output and move them together, but I'm not sure how to achieve this.

How would I go about this?

For what it's worth, I am using Ubuntu 11.10.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

This will extract the filenames from the errors/warnings of exiftool and create a replica directory tree under the folder `unprocessed' with only those files. Didn't try to just move them in a single directory to avoid the risk of overwriting files with the same name but different source dirs.

exiftool ... 2>&1 | tee exiftool.log | egrep '^(Error|Warning)' | \
    sed 's/^Error: .* already exists - //;s/^Warning: .* - //' | \
        while IFS= read -r img; do
            rsync -vR -- "$img" unprocessed/
            #rm -v -- "$img"
        done

The sed part takes into account only the output of the example provided, I'm not familiar with the tool and its possible output messages.

EDIT: The rm part is commented out cause you better try this out first.

share|improve this answer
add comment

The ExifTool solution is to add %c to the file name (or %%c in the -d argument). This will cause a copy number to be added to files with duplicate names.

share|improve this answer
    
Hi and welcome to the site! I'm afraid I don't see how your answer is relevant. The OP wants to move files that return errors by parsing the ExifTool output. Your answer is about adding a copy number to duplicate files which has nothing to do with what is being asked. –  terdon Feb 27 at 13:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.