![]() |
|
|
|
|
|||||||
| 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 |
| Renaming multiple files | jayell | Shell Programming and Scripting | 5 | 02-27-2008 12:17 PM |
| moving and renaming multiple files | rocinante | Shell Programming and Scripting | 1 | 06-07-2007 05:20 PM |
| Renaming multiple files | rmayur | UNIX for Dummies Questions & Answers | 6 | 02-26-2004 12:40 AM |
| Renaming multiple files | jxh461 | Shell Programming and Scripting | 4 | 04-01-2003 03:25 PM |
| renaming multiple files | piltrafa | UNIX for Dummies Questions & Answers | 6 | 11-10-2001 08:27 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Multiple Files Renaming with space
Hi,
I need help how to renaming multiple file. The original file look like this; Test Monday.txt Test Wednesday.txt Test July.txt I have more than hundred file in the directory. How i want to rename all file to a new file name in one time? The new file maybe the same name e.g. TestMonday.txt OR different file name e.g. Test MondayJuly.txt |
| Forum Sponsor | ||
|
|
|
|||
|
i still can't get it. Maybe i give another example, i have original file as below;
Test Fish#10125#STAR.txt Test Fish#52134#MOON.txt Test Fish#32598#CLOUD.txt Test Fish#66789#STORM.txt I need to remove the space between "Test Fish" but i want to do one time for all file before i encrypt it. After i encrypt the file, the file name will become TestFish#10125#STAR_encrypted.txt ... so i need to change back to original file name also in one time for all files. Does anyone know how to do this or know what ‘functions’ I should use??? |
|
||||
|
With the Z-Shell:
Code:
zsh 4.3.4% touch Test\ Fish#10125#STAR.txt Test\ Fish#52134#MOON.txt Test\ Fish#32598#CLOUD.txt Test\ Fish#66789#STORM.txt
zsh 4.3.4% autoload -U zmv
zsh 4.3.4% zmv '*' '${f// /}'
zsh 4.3.4% ls
TestFish#10125#STAR.txt TestFish#32598#CLOUD.txt TestFish#52134#MOON.txt TestFish#66789#STORM.txt
zsh 4.3.4% zmv '*' '$f:r_encrypted.txt'
zsh 4.3.4% ls
TestFish#10125#STAR_encrypted.txt TestFish#52134#MOON_encrypted.txt
TestFish#32598#CLOUD_encrypted.txt TestFish#66789#STORM_encrypted.txt
zsh 4.3.4% zmv '*' '${f//_encrypted/}'
zsh 4.3.4% ls
TestFish#10125#STAR.txt TestFish#32598#CLOUD.txt TestFish#52134#MOON.txt TestFish#66789#STORM.txt
|
|
|||
|
i like a simpler way...thanxs a lot. It work for me. I have a lot a files to rename and if i want to rename the file name from
1) TestFish_done.txt to Test Fish Done.txt, And 2) FishOne_done.txt to FishOne.txt, then how? Last edited by nazri76; 09-22-2007 at 12:05 AM. |
|
||||
|
Case1: TestFish_done.txt to Test Fish Done.txt,
Code:
#!/bin/ksh for oldfile in $(find . -name TestFish*) do newfile="$(echo $oldfile | sed 's/Test/Test /g'|sed 's/\_/ /g')" mv "$oldfile" "$newfile" done Code:
#!/bin/ksh for oldfile in $(find . -name FishOne*) do newfile="$(echo $oldfile | sed 's/_done//g')" mv "$oldfile" "$newfile" done |
||||
| Google The UNIX and Linux Forums |