Delete any file beginning with some character

Discussion in 'Ruby' started by Sarika Patil, Mar 17, 2009.

  1. Sarika Patil

    Sarika Patil Guest

    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-forum.com/.
     
    Sarika Patil, Mar 17, 2009
    #1
    1. Advertising

  2. On Tue, Mar 17, 2009 at 2:38 PM, Sarika Patil
    <> 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-forum.com/.
    >
    >


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

    Andrew Timberlake
    http://ramblingsonrails.com
    http://www.linkedin.com/in/andrewtimberlake

    "I have never let my schooling interfere with my education" - Mark Twain
     
    Andrew Timberlake, Mar 17, 2009
    #2
    1. Advertising

  3. Sarika Patil

    Heesob Park Guest

    Hi,

    2009/3/17 Sarika Patil <>:
    > 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
     
    Heesob Park, Mar 17, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ginette
    Replies:
    0
    Views:
    156
    ginette
    Jun 4, 2004
  2. Uday Thokala
    Replies:
    8
    Views:
    198
    Tom Reilly
    Aug 27, 2007
  3. Jesse B.
    Replies:
    9
    Views:
    260
    Jesse B.
    Mar 27, 2010
  4. PerlFAQ Server
    Replies:
    0
    Views:
    402
    PerlFAQ Server
    Feb 24, 2011
  5. Sebastian
    Replies:
    17
    Views:
    370
    Gene Wirchenko
    Feb 4, 2013
Loading...

Share This Page