Sep 12, 2011

How to rename multiple file extensions with bash

Imagine you have some logfiles with .txt extensions and you want them all to be .log files.
You just need to type this within the logfile directory:

for file in *.txt; do mv $file ${file%.txt}.log; done


There many situations where renaming many files very easly is interessting.

1 comment:

  1. Remember to use "in *.txt". Otherwise spaces could be problematic.

    ReplyDelete