From: "Brian D. Burns" Date: 2013-01-11T19:09:21+09:00 Subject: Re: One liner for filenames On 01/10/2013 06:58 AM, Peter Bailey wrote: > Brian D. B. wrote in post #1091712: >> On 01/08/2013 05:04 PM, Dami叩n M. Gonz叩lez wrote: >>>> ... >>> ruby -e "Dir.foreach('C:/Directory_with_png/') {|file| File.delete(file) >>> unless (file.==('.')) || (file.==('..') || (file.==('filename_1.png'))" >>> >>> Kind regards. >>> >> >> There's certainly many ways to do this, but globing will ignore the dot >> dirs, and is a bit shorter. >> File.delete *Dir['*.png'].reject {|f| f =~ /_1\.png$/ } > > Thanks, Brian. But, even preceding this with "ruby -e" gives me nothing. > Should I make this part of a script instead of it being a one-liner? > That's odd... Works for me under 1.8.7, 1.9.2 and 1.9.3. ruby -e "File.delete *Dir['*.png'].reject {|f| f=~ /_1\.png$/ }" There will be no output. It will just delete the files.