If you wanna rename multiple files at once, removing or modifying same phrase from multiple file names on linux, here is the solution.
For example, imagine you want to remove singer's name in file name (ie. Nirosha_Virajini_) from all the mp3 files listed.Execute this command in terminal,
for file in Nirosha_Virajini_*.mp3; do mv "$file" "${file//Nirosha_Virajini/}" done
And another solution,
rename 's/Nirosha_Virajini_//' *.mp3
Generally
mv
General appearence of above commands, (eg: renaming ABCdefgh.xxx like file names to KLMdefgh.xxx like names)for file in ABC*.xxx; do mv "$file" "${file//ABC/KLM}" done
Including subdirectories
find . -type f -name "ABC*" -print0 | while read -d '' file; do mv "$file" "${file//ABC/KLM}" done
rename
By using commandrename
rename 's/ABC/KLM/' *.xxx
Note: command
renameuses perl.
For Windows users, check this solution
No comments:
Post a Comment