![]() |
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 |
| now to rename multiple files | aoussenko | Shell Programming and Scripting | 4 | 06-11-2008 07:46 PM |
| rename multiple files | antointoronto | Shell Programming and Scripting | 13 | 03-20-2008 10:16 AM |
| Rename part of multiple files | sajjad02 | Shell Programming and Scripting | 4 | 02-22-2005 01:30 PM |
| Rename multiple files | luiz_fer10 | UNIX for Dummies Questions & Answers | 7 | 06-11-2002 09:06 AM |
| Rename Multiple Files | molonede | UNIX for Dummies Questions & Answers | 1 | 11-14-2000 12:40 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
rename multiple files from search output
Variations of multiple renames seems to come up a lot but i can't find the answer to this situation.
Tidying up a directory where people rename files to .working, .bob, .attempt1 & so on. what i am trying to do is: list the file type, & rename from ".whatever" to .fixed. As the ".whatever" is rarely the same, it makes this a bit more than the normal rename all ".a's" to ".b's" if you get my drift. For this particular list of example files i have come up with: for i in `ls WLAN_* | egrep -v 'TRF|fixed' | cut -d "." -f1`;do mv $i.* $i.fixed;done which appears to work fine but a tad "around the houses". I was hoping someone knew a better way/shorter command string. Example files as follows: 1.sh bla1.txt bla2.csv WLAN_20081128_00051453_01.TRF WLAN_20081128_00051468_01.TRF WLAN_20081128_00051469_01.TRF WLAN_20081128_00051470_01.TRF WLAN_clo_20081202_00051984_01.sg-working2 WLAN_clo_20081129_00051540_01.sg-working WLAN_clo_20081129_00051580_01.sg-working WLAN_clo_20081202_00052011_01.still_failed WLAN_clo_20080923_00043115.done WLAN_20081128_00051467_01.TRF WLAN_20081128_00051466_01.TRF WLAN_20081128_00051465_01.TRF WLAN_20081128_00051454_01.TRF WLAN_20081128_00051455_01.TRF WLAN_20081128_00051456_01.TRF WLAN_20081128_00051457_01.TRF WLAN_20081128_00051458_01.TRF WLAN_20081128_00051459_01.TRF WLAN_20081128_00051460_01.TRF WLAN_20081128_00051461_01.fixed WLAN_20081128_00051462_01.fixed WLAN_20081128_00051463_01.TRF WLAN_20081128_00051464_01.TRF WLAN_clo_20081222_00054519_01.test1-sg Desired output ( but this was using my command as above) 1.sh bla1.txt bla2.csv WLAN_20081128_00051453_01.TRF WLAN_20081128_00051468_01.TRF WLAN_20081128_00051469_01.TRF WLAN_20081128_00051470_01.TRF WLAN_clo_20081202_00052011_01.fixed WLAN_clo_20081129_00051580_01.fixed WLAN_clo_20081202_00051984_01.fixed WLAN_clo_20081222_00054519_01.fixed WLAN_clo_20080923_00043115.fixed WLAN_20081128_00051467_01.TRF WLAN_20081128_00051466_01.TRF WLAN_20081128_00051465_01.TRF WLAN_20081128_00051454_01.TRF WLAN_20081128_00051455_01.TRF WLAN_20081128_00051456_01.TRF WLAN_20081128_00051457_01.TRF WLAN_20081128_00051458_01.TRF WLAN_20081128_00051459_01.TRF WLAN_20081128_00051460_01.TRF WLAN_20081128_00051461_01.fixed WLAN_20081128_00051462_01.fixed WLAN_20081128_00051463_01.TRF WLAN_20081128_00051464_01.TRF WLAN_clo_20081129_00051540_01.fixed |
|
||||
|
quite like that
Yep! quite like that. saves mucking around with a delimiter.
made a one liner out of it and worked fine. ls WLAN_* | egrep -v '.fixed|.TRF'| while read file; do mv "$file" "${file%.*}".fixed; done still quite long though. Just me being lazy i suppose. I like your use of the while loop. |
|
||||
|
Quote:
![]() ls WLAN* is not needed - there is no need for a process to be spawned here just shell construct is sufficient here Code:
for file_name in WLAN_* Thanks to cfajohnson ! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|