#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
» pcregrep - UTF-8 aware grep ... in grep perl shell osx mac bash unix utf8 UTF-8 pcre pcregrep multiline heirloom project
» Compiling GNU coreutils on M... in shell osx mac bash unix linux compile man manpage path info gnu seq coreutils infopath
» Compiling GNU sed 4.1.4 on M... in shell osx mac bash unix linux sed gnu case insensitive
» Compile & install git on Mac... in version shell osx mac bash unix linux xcode git control rudix gpg gettext
» ASCII art demo using AAlib in shell osx mac bash unix linux installer ASCII art demo aalib pkg
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails