Loading [MathJax]/jax/output/HTML-CSS/jax.js

Friday, May 8, 2020

Bash Script to Batch Renaming

The following replaces "abcd_mixdown.mp3" to "abcd_vo.mp3" for every mp3 file of the current directory.
1
for mp3 in *.mp3; do renamedmp3=$(echo "$mp3" | sed 's/_mixdown.mp3$/.mp3/'); mv ./"$mp3" ./"$renamedmp3; done"
The next one goes even further, it does the same thing with all current and subdirectory:
1
2
3
4
5
6
7
8
9
#!/bin/bash
 
list=$(find -name '*.mp3' | grep '_mixdown\.mp3');
 
for mp3FilePath in $list
do
    newMp3FilePath=$(echo "$mp3FilePath" | sed 's/_mixdown\.mp3/_vo\.mp3/')
    mv $mp3FilePath $newMp3FilePath
done

No comments:

Post a Comment