![]() |
|
|
|
|
|||||||
| 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 lot of files again | ajp7701 | Shell Programming and Scripting | 11 | 03-31-2008 04:36 PM |
| trying to rename the files in dir | hankooknara | Shell Programming and Scripting | 8 | 07-02-2007 12:36 AM |
| rename many files | fsmadi | SUN Solaris | 4 | 04-30-2007 08:27 AM |
| How to rename files? | CompuTelSystem | UNIX for Dummies Questions & Answers | 9 | 05-14-2002 12:28 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
rename files help
Hi, I've already search for this issue but I found different scripts for rename files, but I don't know how to customize it for my needs.
Here's what I want to do: I have a lot of files inside many directories, like this: /aa/01.txt /aa/02.txt /ab/01.txt /ab/02.txt I want all those files in only one directory, but I have a 01.txt file on each directory, means with the same name, so if I move all the files the last one will overwrite the one with the same name. Because I'm a newby (and with a poor english) I've tried using something like: find . -name '*.txt' -exec mv {}:\ but I don't know how to put a variable inside the {}. I know a very simple script will do the trick, sadly I don't know how to do it. Maybe you could help me with some tip. Thanks a lot!!! |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
How about something like this:
Code:
$ find ./a* -type f | while read filename; do mv ${filename} ~/tmp/dest/`echo "${filename}" | sed -e 's!/!-!g' -e 's/^.-//'`; done
Cheers ZB |
|
#3
|
||||
|
||||
|
Excellent! Exactly what I wanted, and it works great.
Thank u for your wisdom. |
||||
| Google The UNIX and Linux Forums |