baptx Jan 26th, 2014 (edited) 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- if [ $# -gt 0 ]; then
- if [ ! -f $1 ]; then
- echo "Error: file $1 does not exist"
- path=`echo $1 | rev | cut -d / -f 2- | rev`
- if [ $path == $1 ]; then
- if [ $# == 1 ]; then
- for i in `cat $1`
- if [ -f $path/$i ]; then
- let ++nb
- if [ $nb -lt 10 ]; then
- elif [ $nb -lt 100 ]; then
- mv -v $path/$i $path/$digit$nb" - "$i
- elif [ $# == 2 ] && [ $2 == "-r" ]; then
- for i in `ls $path`
- name=`echo $i | cut -d - -f 2- | cut -c 2-`
- for j in `cat $1`
- if [ $path/$name == $path/$j ]; then
- mv -v $path/$i $path/$name
- echo "Playlist files will be renamed by playlist index.
- This script is designed for M3U playlists using relative paths.
- Playlist file needs to be in playlist files folder, subfolders not supported.
- You can use this script with other playlists if you convert them.
- Index uses 3 digits: playlist files are renamed alphabetically up to 999 files.
- Usage: $0 playlist [OPTION]
- OPTION: -r: remove index from filename (add by default)"
RAW Paste Data