[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Delete any file beginning with some character

Sarika Patil

3/17/2009 12:38:00 PM

Hi,

I am trying to delete files in a folder whichever beginning with any
string
but not able to do it?
Command used in rb file is

File.delete("A*.jpg")
--
Posted via http://www.ruby-....

2 Answers

Andrew Timberlake

3/17/2009 12:43:00 PM

0

On Tue, Mar 17, 2009 at 2:38 PM, Sarika Patil
<surekha_patils14@yahoo.co.in> wrote:
> Hi,
>
> I am trying to delete files in a folder whichever beginning with any
> string
> but not able to do it?
> Command used in rb file is
>
> File.delete("A*.jpg")
> --
> Posted via http://www.ruby-....
>
>

Try:
Dir.glob('A*.jpg').each { |file| File.delete(file) }

Andrew Timberlake
http://ramblingso...
http://www.linkedin.com/in/andrew...

"I have never let my schooling interfere with my education" - Mark Twain

Heesob Park

3/17/2009 12:52:00 PM

0

Hi,

2009/3/17 Sarika Patil <surekha_patils14@yahoo.co.in>:
> Hi,
>
> I am trying to delete files in a folder whichever beginning with any
> string
> but not able to do it?
> Command used in rb file is
>
> File.delete("A*.jpg")
require 'fileutils'
FileUtils.rm Dir.glob('A*.jpg')

Regards,

Park Heesob