Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Help w/ Bash Script...
Old 03-31-2009, 07:26 PM Help w/ Bash Script...
Brian07002's Avatar
Defies a Status

Posts: 2,140
Name: ...
Location: ...
Trades: 0
Hi,

How can I rename a jpeg file to the name of the folder it is in? I am using ImageMagick to create a montage for some folders of images, but I would like to rename the output montage file according to the folder it is in. I thought a bash script would be best for this, but if some switch in ImageMagic would work, that would even be better, but I doubt that is possible for this purpose.

Thank you in advance.
-Brian
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-31-2009, 09:20 PM Re: Help w/ Bash Script...
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
You can do it with bash. Could you give an example of the names?

I couldn't make out what you are trying to do.

BTW, not sure if it helps but, on the same topic, a few years ago I wrote a script to batch edit a bunch of files with imagemagick.
http://willcode4beer.com/tips.jsp?set=photoscript
basically, from full-size, create med and thumbs dropping medium size in the 'med' folder and thumb size in the 'thumb' folder.
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 03-31-2009, 09:50 PM Re: Help w/ Bash Script...
Brian07002's Avatar
Defies a Status

Posts: 2,140
Name: ...
Location: ...
Trades: 0
the folder names will have spaces in them if that helps
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 03-31-2009, 10:41 PM Re: Help w/ Bash Script...
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
spaces are no big deal.
can you give an example of what you you want to change into what?
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 03-31-2009, 10:50 PM Re: Help w/ Bash Script...
Brian07002's Avatar
Defies a Status

Posts: 2,140
Name: ...
Location: ...
Trades: 0
I am using ImageMagic in Linux to create montage images from a bunch of jpeg images, and what I would like to do is rename the 'montage' image (the actual montage created image) to the name of the folder that it is located in.

Example: A folder called flowers has 100 flower images in it. I create a montage image using the montage command in linux, and I specify a file for the montage such as montage.jpg...How can I change the filename 'montage.jpg' into the name of the folder called flowers automatically? That's why I thought of the bash script to do this.
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 03-31-2009, 11:01 PM Re: Help w/ Bash Script...
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
ahh, ok, that is much more helpful. You just need to use the replace operators.

Let's say you have a variable "i"
just for example, > export i=redpill/foo.bar

> echo ${i%%/*}.png

will output redpill.png

is that a little closer to what you want?
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 03-31-2009, 11:05 PM Re: Help w/ Bash Script...
Brian07002's Avatar
Defies a Status

Posts: 2,140
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by willcode4beer View Post
ahh, ok, that is much more helpful. You just need to use the replace operators.

Let's say you have a variable "i"
just for example, > export i=redpill/foo.bar

> echo ${i%%/*}.png

will output redpill.png

is that a little closer to what you want?
Exactly!
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 04-01-2009, 02:18 PM Re: Help w/ Bash Script...
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
Just a comment for anyone else reading.
the %%/* means delete everything from the last slash to the right.
if its changed to ##*/ then it deletes everything from the slash to the left.
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help w/ Bash Script...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19957 seconds with 12 queries