Batch Rename File
Posted on December 19th, 2007 by hengdu
I have created a photo album and uploaded to my web server. However, surprisingly, those photos didn’t show up. After troubleshooting, I noticed, some of photos have GB2312 code in the file name. So, I need to batch change them to UTF-8 code. The following is tcsh script, which can replace all “unknown-char” to “photo”.
#!/bin/tcsh
foreach i (*.jpg)
echo $i > /tmp/filename
set j=`sed -e ’s/unknown-char/photo/g’ /tmp/filename`
mv “$i” “$j”
rm /tmp/filename
end
Discussion Area - Leave a Comment