LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-12-2003, 05:46 PM   #1
Franklin
Senior Member
 
Registered: Oct 2002
Distribution: Slackware
Posts: 1,348

Rep: Reputation: 217Reputation: 217Reputation: 217
Need help with very small script.


I'm setting up icewm to use on a laptop and would like to use some of the KDE 16x16 icons, but they need to be changed from .png to .xpm and renamed so that they end in "_16x16".

I can do this one file at a time using ImageMagick from the command line as follows:

>convert filename.png filename_16x16.xpm

but, when I try adapting some of the script examples (not specifically for this) I found searching this sight and googling, I cant get it to work. I'm just a little too noobish with scripting and variables.

Any help would be appreciated.

Sorry for being so dopey

Thanx

 
Old 10-12-2003, 05:57 PM   #2
quatsch
LQ Addict
 
Registered: Aug 2003
Location: New York, NY
Distribution: gentoo, gentooPPC
Posts: 1,661

Rep: Reputation: 48
I think
Code:
rename .png _16x16.xpm *
will do it when issued inside the directory where the files are. Take a look at
man rename

try it out on a backup directory first though.
 
Old 10-12-2003, 09:45 PM   #3
teknomage1
LQ Newbie
 
Registered: Aug 2003
Posts: 17

Rep: Reputation: 0
erm i'm not sure if renaming will address the issue of the file format needing to change...
If you do perl yould use the ImageMagick module for perl and in general the psuedo code for that would be
opendir (DIR, /usr/share/kde/icons);
while <DIR> {
Imagemagick::convert shift
save
}
closedir

or something close to that...haven't used image maick in a long while
 
Old 10-12-2003, 11:09 PM   #4
quatsch
LQ Addict
 
Registered: Aug 2003
Location: New York, NY
Distribution: gentoo, gentooPPC
Posts: 1,661

Rep: Reputation: 48
right. That was silly of me. I was just looking at the renaming part.
 
Old 10-13-2003, 10:42 AM   #5
Franklin
Senior Member
 
Registered: Oct 2002
Distribution: Slackware
Posts: 1,348

Original Poster
Rep: Reputation: 217Reputation: 217Reputation: 217
Hey guys,

Thanks for the responces -

Ya, the first suggestion doesn't quite do it.

Technomage1 - I haven't tried your suggestion yet. But, I have another question for you. If I were to use The Gimp, is ther a way to perform batch file converions from within the program like in paintshop pro and other programs, and then use quatsch's suggestion for batch renaming?

Honestly, Gimp does a better job at conversion.
 
Old 10-13-2003, 01:18 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
What about somethign like this - sorry I haven't had time to test it properly:
Code:
#!/bin/bash

# Pass the dir to look in as the first argument

for file in `find $1 -name *.png`; do
name=`echo $file | sed 's/\.png/_16x16\.xpm/'`
convert $file $name
done
 
Old 10-13-2003, 04:23 PM   #7
Franklin
Senior Member
 
Registered: Oct 2002
Distribution: Slackware
Posts: 1,348

Original Poster
Rep: Reputation: 217Reputation: 217Reputation: 217
Thanks for the scripting suggestions. I'm going to try them tonight.

I have one other question for any of you. After looking further into it, it appears that there is no way for Gimp to do this. You can do some perl scripting provided you have gimpperl installed, however I upgraded to 1.3.x and since its GTK2 base and the perl libs are GTK 1.2 based - well perl is out of the question and I'm back to ImageMagick and convert.

So my question is this. When I did the following - >convert *.png *.xpm I hosed all the file names (I tested on a test file ) getting xxx.xpm.1 through xxx.xpm.125 with xxx not having any relation to the original file name. David, will your script preserve the names at all?

Thanks alot for your input.
 
Old 10-14-2003, 12:16 PM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
The script I suggested should convert images one at a time the convert command would be:
convert /path/to/picture_of_me.png /path/to/picture_of_me_16x16.xpm

So it will keep the first part of the filename the same.
 
Old 10-14-2003, 12:37 PM   #9
Franklin
Senior Member
 
Registered: Oct 2002
Distribution: Slackware
Posts: 1,348

Original Poster
Rep: Reputation: 217Reputation: 217Reputation: 217
Thank you very much.

I'll try it tonight when I get home from work and let you know how it goes.

Steve
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
small script Kassel Programming 2 11-19-2004 04:22 AM
help with a very small script hamish Linux - General 3 06-09-2004 02:10 AM
Please Help with a small script ? juglugs Programming 2 11-14-2001 02:39 AM
Small Script msj Linux - Newbie 2 08-27-2001 06:59 AM
small script msj Programming 1 08-26-2001 11:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration