Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to batch process images but I have a very specific task that I want to do

  1. I do not want to change image type
  2. I want to make them black and white
  3. I want it to create/preserve images and sub folder structure

I did this in Photoshop but it did not preserve folders and sub folder content it just threw every converted file in one directory.

My only hope is Linux :D

Thank you in advance!

You can see different discussion about this here but Basharat Sial worked for me

http://ubuntuforums.org/showthread.php?t=2143992

share|improve this question
    
And the images are in which format: RAW, TIFF, JPEG? Please edit your question with the information. –  user68186 May 10 '13 at 20:02
    
Thank you for the reply the images are in .Png –  Levan May 10 '13 at 20:07
    
@levan Convert images in place or create a new directory structure? –  Basharat Sialvi May 10 '13 at 21:16
    
Do not quite understand what you mean what I want is this for example main folder "F1" contains 4 different sub folders "2003" "2004" "2005" and "2006" and all of this sub folders Constantine 100-120 files so what I want is the new black and white files have the same structure as they where I do not care if it will overwrite or create a new folder all I care is them to be black and white and be in the same folders as they were for example if williams 2003.png was in "2003" I want the new file to be in "2003" as well –  Levan May 10 '13 at 21:21

1 Answer 1

up vote 6 down vote accepted

We can use convert command to convert images to black & white:

convert -colorspace GRAY image.png b-w_image.png

Where image.png is the input image and b-w_image.png is output imgage.

Combining this command with find we can create a bash one liner to convert all the images found under parent directory.

How-to:
Open terminal by hitting Ctrl+Alt+T, cd to parent/main directory and run the following command:

for img in $(find . -iname '*.png'); do echo -n "Converting $img"; convert -colorspace GRAY $img $img && echo ' [Done]'; done

It will convert and overwrite all the images under parent directory. I will suggest to test it on some temporary images and if you're satisfied with the results than run it on actual images.

share|improve this answer
    
I think I love you worked like a charm Thank you very much –  Levan May 10 '13 at 21:52

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.