Peter Scott wrote:
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 won't work as that reads the contents of the files and not the file names.



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
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