• Home
  • Shell
    • Emacs
    • Perl
    • screen
    • sed
  • Ubuntu
    • VNC
  • Web Development
    • Javascript
    • Joomla
    • MySQL
    • osTicket
  • Windows
    • Gimp

BASH> Mass rename files

Mar04
2015
Written by Scott Rowley
for file in *.html; do mv -- "$file" "${file%.html}.php"; done
drwxrwxr-x 11 apache sas 4096 Mar 4 12:08 .
drwxrwxr-x 4 apache sas 4096 Feb 26 17:38 ..
-rw-rw-r-- 1 sasowner sas 10763362 Mar 4 11:48 AdminTheme.zip
drwxrwxr-x 4 sasowner sas 4096 Dec 8 2012 bootstrap
-rw-rw-r-- 1 sasowner sas 18949 Dec 8 2012 calendar.html
-rw-rw-r-- 1 sasowner sas 20676 Dec 8 2012 charts.html
drwxrwxr-x 4 sasowner sas 4096 Dec 8 2012 css
drwxrwxr-x 4 sasowner sas 4096 Dec 8 2012 custom-plugins
-rw-rw-r-- 1 sasowner sas 15572 Dec 8 2012 error.html
drwxrwxr-x 2 sasowner sas 4096 Dec 8 2012 example
-rw-rw-r-- 1 sasowner sas 19769 Dec 8 2012 files.html
-rw-rw-r-- 1 sasowner sas 54023 Dec 8 2012 form_elements.html
-rw-rw-r-- 1 sasowner sas 48582 Dec 8 2012 form_layouts.html
-rw-rw-r-- 1 sasowner sas 48867 Dec 8 2012 form_wizard.html
-rw-rw-r-- 1 sasowner sas 29210 Dec 8 2012 gallery.html
-rw-rw-r-- 1 sasowner sas 26691 Dec 8 2012 grids.html
-rw-rw-r-- 1 sasowner sas 286390 Dec 8 2012 icons.html
drwxrwxr-x 3 sasowner sas 4096 Dec 8 2012 images
-rw-rw-r-- 1 sasowner sas 45088 Mar 4 12:08 index.php
drwxrwxr-x 5 sasowner sas 4096 Dec 8 2012 js
drwxrwxr-x 5 sasowner sas 4096 Dec 8 2012 jui
-rw-rw-r-- 1 sasowner sas 2998 Dec 8 2012 login.html
-rw-rw-r-- 1 sasowner sas 1780 Mar 4 12:08 navigation.php
drwxrwxr-x 2 sasowner sas 4096 Dec 8 2012 php
drwxrwxr-x 17 sasowner sas 4096 Dec 8 2012 plugins
-rw-rw-r-- 1 sasowner sas 69763 Dec 8 2012 table.html
-rw-rw-r-- 1 sasowner sas 27285 Dec 8 2012 typography.html
-rw-rw-r-- 1 sasowner sas 61362 Dec 8 2012 widgets.html

After

drwxrwxr-x 11 apache sas 4096 Mar 4 12:08 .
drwxrwxr-x 4 apache sas 4096 Feb 26 17:38 ..
-rw-rw-r-- 1 sasowner sas 10763362 Mar 4 11:48 AdminTheme.zip
drwxrwxr-x 4 sasowner sas 4096 Dec 8 2012 bootstrap
-rw-rw-r-- 1 sasowner sas 18949 Dec 8 2012 calendar.html
-rw-rw-r-- 1 sasowner sas 20676 Dec 8 2012 charts.html
drwxrwxr-x 4 sasowner sas 4096 Dec 8 2012 css
drwxrwxr-x 4 sasowner sas 4096 Dec 8 2012 custom-plugins
-rw-rw-r-- 1 sasowner sas 15572 Dec 8 2012 error.html
drwxrwxr-x 2 sasowner sas 4096 Dec 8 2012 example
-rw-rw-r-- 1 sasowner sas 19769 Dec 8 2012 files.html
-rw-rw-r-- 1 sasowner sas 54023 Dec 8 2012 form_elements.html
-rw-rw-r-- 1 sasowner sas 48582 Dec 8 2012 form_layouts.html
-rw-rw-r-- 1 sasowner sas 48867 Dec 8 2012 form_wizard.html
-rw-rw-r-- 1 sasowner sas 29210 Dec 8 2012 gallery.html
-rw-rw-r-- 1 sasowner sas 26691 Dec 8 2012 grids.html
-rw-rw-r-- 1 sasowner sas 286390 Dec 8 2012 icons.html
drwxrwxr-x 3 sasowner sas 4096 Dec 8 2012 images
-rw-rw-r-- 1 sasowner sas 45088 Mar 4 12:08 index.php
drwxrwxr-x 5 sasowner sas 4096 Dec 8 2012 js
drwxrwxr-x 5 sasowner sas 4096 Dec 8 2012 jui
-rw-rw-r-- 1 sasowner sas 2998 Dec 8 2012 login.html
-rw-rw-r-- 1 sasowner sas 1780 Mar 4 12:08 navigation.php
drwxrwxr-x 2 sasowner sas 4096 Dec 8 2012 php
drwxrwxr-x 17 sasowner sas 4096 Dec 8 2012 plugins
-rw-rw-r-- 1 sasowner sas 69763 Dec 8 2012 table.html
-rw-rw-r-- 1 sasowner sas 27285 Dec 8 2012 typography.html
-rw-rw-r-- 1 sasowner sas 61362 Dec 8 2012 widgets.html
Posted in Web Development
« Objective-C> Set all iOS keyboard to black (Alert)

Corrections? Questions? Comments?

Find an error?
Everything work out great for you?
Have some feedback?
Like to see something added to the article?

PLEASE leave us a comment after the article and let us know how we are doing, or if something needs corrected, improved or clarified.

Thank you!
- The Management

Advertisement

Sudo Bash
By Geeks - For Geeks

Back to Top