![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Rename a file name | Aswarth | Shell Programming and Scripting | 0 | 06-04-2008 11:18 AM |
| rename file to file.ext.datetime | tripsat | Shell Programming and Scripting | 2 | 09-20-2007 01:12 PM |
| Not able to rename file | MANISH KU | Shell Programming and Scripting | 2 | 06-27-2007 01:07 AM |
| File rename | redlotus72 | UNIX for Dummies Questions & Answers | 1 | 03-09-2006 07:52 AM |
| Rename part of multiple files | sajjad02 | Shell Programming and Scripting | 4 | 02-22-2005 09:30 AM |
|
|
Submit Tools | LinkBack | Thread Tools | 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 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 |
| Forum Sponsor | ||
|
|
|
|||
|
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 |