Last active
December 29, 2015 07:39
-
-
Save imzjy/7637464 to your computer and use it in GitHub Desktop.
rename MP3 files, and remove first 4 characters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [[ ! -d $1 ]]; then | |
echo "please specific a MP3 directory" | |
exit; | |
fi | |
SAVEIFS=$IFS | |
IFS=$( echo -en "\n\b" ) #fix mp3 files contain a space | |
for file in $( find $1 -name *.mp3 ); do | |
echo $file | |
MP3NAME=$( basename $file) | |
PATHNAME=$( dirname $file ) | |
mv $PATHNAME/$MP3NAME $PATHNAME/$( echo $MP3NAME | cut -c 5- ) | |
done | |
IFS=$SAVEIFS | |
# rename the mp3 files, like 010-流年.mp3 -> 流年.mp3 | |
# reference: http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment