#alter the regex to suit your needs, each () will return a submatch my $regex = qr!(\d\d)[-](\d\d)[-](\d\d)[_](\d\d\d\d)!; while(<*.jpg>) { $oldname = $_; if ($oldname=~m/$regex/) { #$1,$2,etc are submatchs rename $oldname,$3.$2.$1.$4.".jpg"; } }
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Rename files by reordering existing data (regular expression capturing submatches) (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» Reverse DNS from command line in shell osx unix linux
» Search for open files that w... in shell osx mac server command line
» Measure the daily number of ... in email date perl shell bash mime day mailbox
» get rid of mac's ._ meta fil... in shell mac unix linux
» Regex-based file/folder sear... in grep regex shell osx mac mdfind
» grep-based phrase search wit... in grep regex shell osx mac mdfind
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails