Linux: bulk file renaming

Open baby

Linux: bulk file renaming

Postby intodis » 08 Aug 2010, 12:08

Bulk renaming using regular expressions

rename 's/01/02/' *01.txt
(will rename all .txt files who end in in 01 to end in 02)
rename 's/\+//' *
(will rename all files containing a + removing the +)

Strip/removing the file extension from its file name
Need to install csh e.g. sudo apt-get install csh

# csh
% ls
t1.dat t2.dat t3.dat t4.dat t5.dat
% foreach filename (*.dat)
? mv $filename `echo $filename | sed 's/.dat//g'`
? end
% ls
t1 t2 t3 t4 t5
Site Admin
Posts: 204
Joined: 30 Mar 2006, 20:57

Return to Ubuntu/Linux

Who is online

Users browsing this forum: No registered users and 1 guest