how do i remove a word from multiple file names?
hey all lets say i have some files with names like these:
Quote:
Code:
for files in *.rar; do mv “$files” `echo $files | tr ‘oldword‘ ‘newword’`; done |
for files in `ls *.rar`; do mv $files `echo $files | sed s/oldword/newword/g`; done
|
perfect thanks for the quick reply :)
|
no need to use external commands. with bash
Code:
for file in *.rar; do echo mv "$file" "${file/Word/NewWord}"; done |
Quote:
|
Quote:
Quote:
2) using "|" and calling external commands creates extra overheads. The shell provides simple substitution, so try to use it whenever possible |
Quote:
Thanks Ghostdog, Sasha |
You have many answers, so I just thought I'd point out that the primary problem with your original attempt is that tr only replaces single characters.
Evo2. |
All times are GMT -5. The time now is 05:49 AM. |