Script to change several filename
I need to change many filename that have similar name.
Example: I have about 100 file named "hello world" and I want change all them name in "hi world". I've tried some command like "find" and "mv" but I didn't manage to make it... Thanks.. by the way Hi all!! Jan |
Put an if sentence and a concatenation into the following script:
#!/usr/bin/tcsh #filer i et directory foreach fil (`find /home/you/path -type f`) mv $fil $newfilname end |
Perhaps I didn't explain very well.. sorry for my bad english..
I have several similar files... 00001-hello-world-00001 00002-hello-world-00002 00003-hello-world-00003 ... ... I want to change for all these files the word "hello" with the word "hi" so that I'll have the files named 00001-hi-world-00001 00002-hi-world-00002 ... |
up
|
This seems to work, although its not clear form your description if all the files are in the ssame directory or in different directories. If they are in different directories then this won't work without some modification.
for f in *; do mv "$f" "`echo $f | sed s/hello-world/hi-world/`"; done Be careful with all the " and ` s!! There is probably a better way of doing this, and I would like to see other people's improved suggestions, but this should do for your purposes. Mark. |
I don't mind the better way, it's important that it works.. :)
Anyway, for the moment I can't try your script. I've just resolved the problem in another way... manually one by one!! Surely I'll try your script the next time and I'll make you to know as it goes... :) Thanks Bye at all |
All times are GMT -5. The time now is 11:08 AM. |