Reese Knowledgebase

Rename batch of files

View Kristian Reese's profile on LinkedIn


If you like this article, please +1 or Recommend via FB with the provided buttons above:

Article ID: 163
by: Reese K.
Posted: 25 Mar, 2015
Last updated: 25 Mar, 2015
Views: 642

How to rename a batch or group of files

kreese@MacBook ~/wbsvr $ ls -l
total 200
-rwx------  1 kreese  1575811233  34652 Mar 19 16:49 httpd.conf
-rw-r--r--  1 kreese  1575811233  13609 Mar 25 08:30 vhost1.conf.txt
-rw-r--r--  1 kreese  1575811233  21861 Mar 25 08:30 vhost2.conf.txt
-rw-r--r--  1 kreese  1575811233  21883 Mar 25 08:30 vhost3.conf.txt
kreese@MacBook ~/wbsvr $ 
kreese@MacBook ~/wbsvr $ for file in *.txt; do x=$(basename $file .txt); mv $file $x; done
kreese@MacBook ~/wbsvr $ 
kreese@MacBook ~/wbsvr $ ls -l
total 200
-rwx------  1 kreese  1575811233  34652 Mar 19 16:49 httpd.conf
-rw-r--r--  1 kreese  1575811233  13609 Mar 25 08:30 vhost1.conf
-rw-r--r--  1 kreese  1575811233  21861 Mar 25 08:30 vhost2.conf
-rw-r--r--  1 kreese  1575811233  21883 Mar 25 08:30 vhost3.conf
This article was:   Helpful | Not Helpful
Also listed in
folder UNIX -> Linux

Prev   Next
Monitor Log for pattern match and trigger action     How to redirect command line results into while loop

RSS