Forum: Ruby Delete any file beginning with some character

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sarika P. (Guest)
on 2009-03-17 14:40
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")
Andrew T. (Guest)
on 2009-03-17 14:47
(Received via mailing list)
On Tue, Mar 17, 2009 at 2:38 PM, Sarika P.
<removed_email_address@domain.invalid> wrote:
>
>

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

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

"I have never let my schooling interfere with my education" - Mark Twain
Heesob P. (Guest)
on 2009-03-17 14:55
(Received via mailing list)
Hi,

2009/3/17 Sarika P. <removed_email_address@domain.invalid>:
> 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 H.
This topic is locked and can not be replied to.