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.
B42bcfc9013a276f5d768a0e6b528a29?d=identicon&s=25 Sarika Patil (sarika)
on 2009-03-17 13: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")
5772c599ccab3081e0fffb1d54f3b6de?d=identicon&s=25 Andrew Timberlake (andrewtimberlake)
on 2009-03-17 13:47
(Received via mailing list)
On Tue, Mar 17, 2009 at 2:38 PM, Sarika Patil
<surekha_patils14@yahoo.co.in> wrote:
>
>

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
666b4e17b4bb0e2d999037a25f65a7cb?d=identicon&s=25 Heesob Park (phasis)
on 2009-03-17 13:55
(Received via mailing list)
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
This topic is locked and can not be replied to.