Results 1 to 4 of 4

Thread: Batch Script to Convert PNG to XPM

  1. #1
    Join Date
    Jul 2010
    Posts
    76

    Batch Script to Convert PNG to XPM

    I am able go with the convert command for the conversion of a single image from PNG to XPM, but unable to get (my previous) script to be in functioning. I need the same to convert a directory of PNGs to XPM. Any suggestion would be appreciated. Thank you very much !

    echo "Script Starting.."
    cd /home/user/Pictures/icons
    echo "start For loop"
    for pic in 'ls *.png'
    do
    echo "converting $pic"
    convert $pic $pic.xpm
    done
    echo "finished"

  2. #2
    Join Date
    Nov 2005
    Posts
    3,026

    Re: Batch Script to Convert PNG to XPM

    Do you get what I have performed at that place ? There are two characters in red that were single quotes in your code, have been reverted into the backticks. That is placed on the same key onto the standard system keyboard as the tilde ~ is, in the above left corner.

    I would suggest that you make the difference more obvious, by performing the same instead:

    echo "Script Starting.."
    cd /home/user/Pictures/icons
    echo "start For loop"
    for pic in $(ls *.png)
    do
    echo "converting $pic"
    convert $pic $pic.xpm
    done
    echo "finished"

  3. #3
    Join Date
    Apr 2008
    Posts
    4,089

    Re: Batch Script to Convert PNG to XPM

    That should resolve the complexities . But there will be single minor flaw. File aaa.png would be converted, for instance , and the name of the newly generated file will be aaa.png.xpm. I am just considering that you need, instead, aaa.xpm. If that is the situation, you have to modify the lines in suggested .

    for pic in $(ls *.png)
    do
    echo "converting $pic"
    convert $pic $(basename $pic.xpm .xpm)
    done

  4. #4
    Join Date
    Jul 2010
    Posts
    237

    Re: Batch Script to Convert PNG to XPM

    Thank you very much for the suggestion and I never would have got the tick mark (vs) quote issue. The script executes and I receive the "converting pic" messages as every file is getting processed. But I never search the output/xpm files. The script permission configured as 755, and I have executed the same as root and user. But still I am not getting any files. I am again reading the documentation on permissions (I considered that is the issue) but if you suspect some other issues please let me know about this . Thanks again.

Similar Threads

  1. Batch Script Issue
    By spmaguire in forum Software Development
    Replies: 3
    Last Post: 04-09-2013, 10:41 AM
  2. Encrypt batch script content
    By Aaliya Seth in forum Software Development
    Replies: 4
    Last Post: 01-04-2010, 01:10 PM
  3. Batch script to delete directory
    By Logan 2 in forum Software Development
    Replies: 4
    Last Post: 01-04-2010, 12:31 PM
  4. Need a batch script to map drive
    By Common in forum Networking & Security
    Replies: 3
    Last Post: 06-07-2009, 07:42 PM
  5. How can I play a Wav file from batch/cmd script?
    By NaFula in forum Windows Vista Performance
    Replies: 3
    Last Post: 13-09-2008, 09:21 PM

Posting Permissions

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