You're here: Snippet Directory » UNIX Admin (199)
Language:

batch-string-rename

Language: English
Programming Language: Unix Shell
Published by: tkchan [not registered]
Last Update: 5/15/2006
Views: 1683


Description

Calls string-rename to do multiple string replaces on filenames.

Code

1 #!/bin/bash 2 # 3 # batch-string-rename - Batch script to rename with replaced strings 4 # 5 # Usage: batch-string-rename STRING_TARGET STRING_REPLACE FILETYPE 6 # 7 # Example: batch-string-rename "_" "\ " mp3 8 # will call string-rename and batch process rename all mp3 files 9 # 10 # tkchan@rescomp.berkeley.edu 11 # 12 13 case $# in 14 3) 15 ls *.$3 | sed "s/[ ]/?/g" > .temp.filelist 16 for i in $(cat .temp.filelist); do 17 string-rename "$1" "$2" "$i"; 18 done 19 rm .temp.filelist 20 ;; 21 *) 22 echo "Usage: batch-string-rename STRING_TARGET STRING_REPLACE FILETYPE" 23 echo 24 echo "Example: batch-string-rename \"_\" \"\ \" mp3" 25 echo " will call string-rename and batch process rename all mp3 files" 26 echo " replacing all \"_\" with \" \"" 27 exit 1 28 esac 29 exit 0 30

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS