On Thu, 11 Aug 2011 16:17:51 -0700, siegfried wrote:
> This works! 

Really?  I get "find: missing argument to `-exec'"

I think your command also renames directories.  You want that?

> Is there a way to do it with less typing? How can I do it
> without creating a temporary variable "@p"? Thanks,
> siegfried
> 
> find /xyz -exec perl -e 'foreach(@ARGV){ my @p=split "/"; rename $_,
> "./$p[$#p].txt" } '

Try this:

find /xyz -type f -print0 | perl -F/ -0lane 'rename $_,"$F[-1].txt" or 
warn $!'

That should give you a good excuse to read perlrun :-)

-- 
Peter Scott
http://www.perlmedic.com/     http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274
http://www.oreillyschool.com/courses/perl4/

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to