Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to change filenames?[SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
schorsche
Apprentice
Apprentice


Joined: 27 Jan 2005
Posts: 230

PostPosted: Sat Oct 06, 2007 8:40 pm    Post subject: How to change filenames?[SOLVED] Reply with quote

Hello, I want to truncate file
P8240586.JPG-9b9576feacd2d4c294abd86b31793c82

to 1.jpg

How would I do this?


Last edited by schorsche on Sat Oct 06, 2007 9:10 pm; edited 1 time in total
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10590
Location: Somewhere over Atlanta, Georgia

PostPosted: Sat Oct 06, 2007 8:44 pm    Post subject: Reply with quote

Huh? Surely you're not just asking how to rename, are you? Well, anyway, at a shell prompt, type
Code:
mv P8240586.JPG-9b9576feacd2d4c294abd86b31793c82 1.jpg
If the file name is reasonably unique, type a few letters of it and then a tab, and Bash will finish off the filename for you. You may be interested in Introduction to Linux, a Hands on Guide.

- John
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Sat Oct 06, 2007 8:49 pm    Post subject: Re: How to change filenames? Reply with quote

schorsche wrote:
Hello, I want to truncate file
P8240586.JPG-9b9576feacd2d4c294abd86b31793c82

to 1.jpg

How would I do this?


If you just want to manually rename some files, your question has been already answered. If you want some kind of automation to rename a bunch of files that has the ".JPG" pattern on their names, you could do something like this:

Code:
j=1; for i in *.[jJ][pP][gG]*; do echo mv "$i" "$j.jpg"; j=$(($j+1)); done


If you like the results, erase the "echo" part, and the changes will be applied.
Back to top
View user's profile Send private message
schorsche
Apprentice
Apprentice


Joined: 27 Jan 2005
Posts: 230

PostPosted: Sat Oct 06, 2007 9:10 pm    Post subject: Reply with quote

That worked a treat, thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum