#!/bin/sh
I=10
while [ $I -gt 1 ]; do
rename " " _ *
rename "(" _ *
rename ")" _ *
rename "'" _ *
rename "&" _ *
rename "[" _ *
rename "]" _ *
rename "?" _ *
rename ":" _ *
rename "!" _ *
I=`expr $I - 1`
done
Version 2 - with recursion:
#!/bin/sh
I=10
while [ $I -gt 1 ]; do
find . -name "* *" -print -exec rename " " _ {} \;
find . -name "*&*" -print -exec rename "&" _ {} \;
find . -name "*(*" -print -exec rename "(" _ {} \;
find . -name "*)*" -print -exec rename ")" _ {} \;
find . -name "*'*" -print -exec rename "'" _ {} \;
find . -name "*[*" -print -exec rename "[" _ {} \;
find . -name "*]*" -print -exec rename "]" _ {} \;
find . -name "*:*" -print -exec rename ":" _ {} \;
find . -name "*|*" -print -exec rename "|" _ {} \;
find . -name "*%*" -print -exec rename "%" _ {} \;
find . -name "*\**" -print -exec rename "*" _ {} \;
find . -name "*\!*" -print -exec rename "!" _ {} \;
find . -name "*\?*" -print -exec rename "?" _ {} \;
I=`expr $I - 1`
done
The above will remove spaces and other annoying special characters in Linux file names.
ReplyDelete