Question
In a directory, I have a bunch of *.html files. I'd like to rename them all to *.txt by using the bash shell.
How-To
- test.sh
- #!/bin/sh
- for file in *.html; do
- new_ft=${file%*.html}
- echo "$new_ft"
- mv "$file" "${new_ft}.txt"
- done
* How do I rename the extension for a batch of files?
* 鳥哥 - 認識與學習 BASH: 變數內容的刪除、取代與替換
沒有留言:
張貼留言