Path: utzoo!utgpu!cs.utexas.edu!uwm.edu!rutgers!sun-barr!newstop!texsun!letni!mic!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: alt.sources Subject: Re: Neat utility to convert uppercase filenames Message-ID: <110060@convex.convex.com> Date: 8 Dec 90 03:40:18 GMT References: <76@gdx.UUCP> <28682@usc> Sender: news@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 29 Here's one version of rename, a generic utility to perform infinite contortions on your filenames. It's surely more powerful than anything of its ilk I've ever seen before. --tom #!/usr/bin/perl # # rename script examples from lwall: # rename 's/\.orig$//' *.orig # rename 'y/A-Z/a-z/ unless /^Make/' * # rename '$_ .= ".bad"' *.f # rename 'print "$_: "; s/foo/bar/ if =~ /^y/i' * # # shows good use of eval operator $op = shift; for (@ARGV) { $was = $_; eval $op; die $@ if $@; rename($was,$_) unless $was eq $_; } -- Tom Christiansen tchrist@convex.com convex!tchrist "With a kernel dive, all things are possible, but it sure makes it hard to look at yourself in the mirror the next morning." -me