![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Rename a file name | Aswarth | Shell Programming and Scripting | 0 | 06-04-2008 02:18 PM |
| rename file to file.ext.datetime | tripsat | Shell Programming and Scripting | 2 | 09-20-2007 04:12 PM |
| Not able to rename file | MANISH KU | Shell Programming and Scripting | 2 | 06-27-2007 04:07 AM |
| File rename | redlotus72 | UNIX for Dummies Questions & Answers | 1 | 03-09-2006 11:52 AM |
| Rename part of multiple files | sajjad02 | Shell Programming and Scripting | 4 | 02-22-2005 01:30 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi there,
I hope someone can help me with this problem : I have a directory (/var/www/file/imgprofil) which contains about 10000 JPG files. They have a naming convention thus : prefix-date-key-suffix.jpg they all have the prefix p-20050608- then AAAA is a 4 letter code the suffix is either -g / -v / -m or no suffix the file extension is always .jpg sample : p-20050608-AFWC-g.jpg p-20050608-AFWC-m.jpg p-20050608-AFWC-v.jpg p-20050608-AFWC.jpg p-20050608-AFWD-g.jpg p-20050608-AFWD-m.jpg p-20050608-AFWD-v.jpg p-20050608-AFWD.jpg My problem is that some of the files have 1 or more lower case letters in the 4 letter code, so they are like this : p-20050608-Ajyd-g.jpg p-20050608-Ajyd-m.jpg p-20050608-Ajyd-v.jpg p-20050608-Ajyd.jpg p-20050608-Ajyw-g.jpg p-20050608-Ajyw-m.jpg p-20050608-Ajyw-v.jpg p-20050608-Ajyw.jpg Now, Unix being the case sensitive angel that it is I need to transform these lowercase "keys" filenames into uppercase, so the sample would be :p-20050608-AJYD-g.jpg p-20050608-AJYD-m.jpg p-20050608-AJYD-v.jpg p-20050608-AJYD.jpg p-20050608-AJYW-g.jpg p-20050608-AJYW-m.jpg p-20050608-AJYW-v.jpg p-20050608-AJYW.jpg While of course keeping the lowercase prefix (p-) and suffix (-g /-m / -v) and the lowercase file extension (.jpg) I hope this is clear and that someone can help with this, Thanks, Steve |
|
||||
|
THis is for 1 particular case
Quote:
This is for 1 particular case ( aiyd ) and not for all the options Isnt it ? |
|
||||
|
Perfectly Agree,
But i could accomplish only that much with my knowledge of sed. Can anyone give a general one with sed. mv is taken for granted. for filename in *.jpg; do newname=`echo $filename | sed -e 's/Aiyd/AIYD/g'` mv $filename newname done |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|