Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4026256
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:56:51+00:00 2026-05-20T10:56:51+00:00

I need a very simple shell script that processes all images on a folder

  • 0

I need a very simple shell script that processes all images on a folder and changes its size. The image processing is done with gimp script-fu and the only thing that the shell script have to do is the for loop.

I made this:

#!/bin/sh

mkdir processed
for image in `ls`
do
    if [ $image != "script.sh" ]
    then
        if [ $image != "processed" ]
        then
            gimp -i -b '(let* ( (img (gimp-file-load 1 "1.jpg" "1.jpg")) (drw (gimp-image-get-active-drawable (car img))) ) (gimp-image-scale-full 1 400 300 3) (file-jpeg-save 1 (car img) (car drw) "processed/1.jpg" "1.jpg" 0.6 0 1 1 "" 3 0 0 2) (gimp-quit 0) )'
        fi
    fi
done

This code works but, in the script-fu code I put 1.jpg as the file name and, of course, I want that there appears the value of the $image variable. My shell scripting knowledge is limited and I’m lost with the way I have to put the variable inside the command.

Can you help me? Thanks for your time 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:56:51+00:00Added an answer on May 20, 2026 at 10:56 am

    Use for image in * instead of ls.

    To pass the variable to the Gimp script and preserve the quotes for Gimp, you’ll need to use double quotes for the outer ones and escape the inner quotes:

    gimp -i -b "(let* ( (img (gimp-file-load 1 \"$image\" \"$image\")) (drw (gimp-image-get-active-drawable (car img))) ) (gimp-image-scale-full 1 400 300 3) (file-jpeg-save 1 (car img) (car drw) \"processed/$image\" \"$image\" 0.6 0 1 1 "" 3 0 0 2) (gimp-quit 0) )"
    

    You can also simplify your script:

    mkdir processed
    for image in *.jpg
    do
        if [[ -f $image ]]
        then
            gimp ...
        fi
    done
    

    If you want to include more extensions:

    for image in *.{jpg,JPG,jpeg,JPEG,gif,GIF,png,PNG}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have very simple problem. I need to create model, that represent element of
I need a shell script that deletes 1000 rows from a massive database until
Is there a simple shell command/script that supports excluding certain files/folders from being archived?
I need a very simple c++ function that calls a lua function that returns
i need to build a very simple wizard that will import a text file
I need a very simple and clear example of how to create an OCX
I need to be able to merge two (very simple) JavaScript objects at runtime.
I need to do a few very simple URL manipulations in Java. Like get
I need a very simple function to draw a bunch of lines with anti-aliasing.
I need to build a very simple administration interface for maintaining website content. Not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.