View previous topic :: View next topic |
Author |
Message |
schorsche Apprentice
Joined: 27 Jan 2005 Posts: 230
|
Posted: Sat Oct 06, 2007 8:40 pm Post subject: How to change filenames?[SOLVED] |
|
|
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 |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10590 Location: Somewhere over Atlanta, Georgia
|
Posted: Sat Oct 06, 2007 8:44 pm Post subject: |
|
|
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 |
|
|
i92guboj Bodhisattva
Joined: 30 Nov 2004 Posts: 10315 Location: Córdoba (Spain)
|
Posted: Sat Oct 06, 2007 8:49 pm Post subject: Re: How to change filenames? |
|
|
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 |
|
|
schorsche Apprentice
Joined: 27 Jan 2005 Posts: 230
|
Posted: Sat Oct 06, 2007 9:10 pm Post subject: |
|
|
That worked a treat, thanks! |
|
Back to top |
|
|
|