9. Nov. 2008

Sometimes a situation can occur in which we need to do a bulk rename of files. Thinking about a situation in which we want to rename all .html files to make them inaccessible for a while or we want to rename all downloaded photos from your camera perhaps?

Being on Unix this can be done easily by using a simple 4 line shell script like the one below:

for a in *.html; do
  t=`echo $a | sed ‘s/.html$/.html.en/’`
  mv $a $t
done

In this example we will rename all .html file to .html.en e.q. index.html.en which comes handy in case you want to add another set of webpages to your server containing and supporting a 2nd languge.

Guess it is not really necessary to tell you that you should make a copy of your files first??

No comments yet

No comments yet.

Sorry, the comment form is closed at this time.