Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What I need to do is a program that given (as a command line argument) a directory with more directoreies inside, and 4 Pics inside of each dir, the program makes a thumbnail of the 4 files and glues them together (2 rows, 2 columns) and renames that image to the name of the directory.

I think it could be done with a combination of a program and shell scripting (I'm experienced in M$, but new to linux).

Some real examples would be great.

Thanx in advance

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Look for ImageMagick. This example should get you going.

Use find and xargs to run it in several directories:

find path -type d -print0 | xargs -0 -i montage ... -size 512x512 '{}/*_orig.*[120x90]' ...

xargs will replace {} with each path that find finds. Replace path with the root directory in which you want the search to begin.

-type d will just return directories.

-print0 makes sure that spaces and other special characters are handled correctly. The option -0 to xargs is the opposite; otherwise xargs would split the the input at every whitespace (tabs, blanks, newlines).

share|improve this answer
    
Why not using the -exec action of find? –  cYrus Jan 10 '11 at 11:34
    
-exec works in this case, too. I'm not sure anymore why I prefer xargs - maybe because the same general pattern allows me to run the same command with a single and several arguments. –  Aaron Digulla Jan 10 '11 at 13:48
    
Exactly what I needed, Namaste..Ps: long live the command line :) –  Webmaster Jan 10 '11 at 19:23

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.