On Tue, Jan 8, 2013 at 9:48 PM, Peter Bailey <[email protected]> wrote:
> Hello,
> Can someone help me to write a Ruby one-liner to remove all the files
> except one in a list of files? I have a list of pages of an original
> PDF. Each page has been converted to a PNG file. They're each numbered
> with an underscore and a number at their end.
>
> filename_1.png
> filename_2.png
> filename_3.png
> ...
>
> I need to basically delete all of the files except for the first one,
> the one with the "_1" suffix at the end. Can I do that wiith a
> one-liner?
ruby -r pathname -e 'Pathname.glob("*[^1].png").each(&:delete)'
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
-- You received this message because you are subscribed to the Google Groups
ruby-talk-google group. To post to this group, send email to
[email protected]. To unsubscribe from this group, send email
to [email protected]. For more options, visit this
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en