Thursday, July 24, 2014

Re: [LINUX_Newbies] Re: Rename Photos?

 

On Thu, Jul 24, 2014 at 07:09:17AM -0700, jpwalker@fastmail.fm [LINUX_Newbies] wrote:
> I have several different sets of photos that all have them same numbers. I would like to rename them as- 1- 100A, or 1-100B for example. How can I do this from the command line?

Assuming you have them in a directory called photos, while in that
directory

First test it.

for i in *.jpg;do echo mv "$i" "${i%%.jpg}" A.jpg;done

This will show you what it would do. For example,in a directory that has
two pictures, 1.jpg and 2.jpg I ran the command and get

for i in *.jpg; do echo mv "$i" "${i%%.jpg}"A.jpg;done
mv 1.jpg 1A.jpg
mv 2.jpg 2A.jpg

Once you've tested it by using echo you can now it for real.

for i in *.jpg;do mv "$i" "${i%%.jpg}" A.jpg;done

In this case, what we're doing is what's called a for loop, (because it
uses the word for, as opposed to a while loop). for i in *.jpg means for a
a variable, which we're callling i, in a group, in this case, any file
ending with .jpg, move, (in this case, that means rename) the file. The
${i%% means that we're going to get rid of whatever comes after the %%, in
this case, .jpg, then outside of the bracket, put in a letter A and put the
.jpg back. There are other ways and scripts, but that is one of the
simpler methods, IMHO.

--
Scott Robbins
PGP keyID EB3467D6
( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

__._,_.___

Posted by: Scott <scottro@nyc.rr.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (7)

Yahoo Groups
Improved Group Homepage!
The About page of your Group now gives you a heads up display of recent activity, including the latest photos and files

Yahoo Groups
Control your view and sort preferences per Yahoo Group
You can now control your default Sort & View Preferences for Conversations, Photos and Files in the membership settings page.

To unsubscribe from this list, please email LINUX_Newbies-unsubscribe@yahoogroups.com & you will be removed.

.

__,_._,___

No comments:

Post a Comment