From: Alexander McMillan Date: 2012-11-30T19:50:40+09:00 Subject: Re: removing directories --_ffde6853-e3d1-49ee-860c-6ff9fb61acad_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Take a look at a lesson on oldkingjames.org FilUtils is used to delete dire= ctory even with files inside. > Date: Thu=2C 29 Nov 2012 22:39:52 +0900 > From: lists@ruby-forum.com > Subject: removing directories > To: ruby-talk@ruby-lang.org >=20 > Hello=2C > I've googled around and I've discovered that "FileUtils.rm_rf('#{dir}') > will remove a directory. But=2C I can't get it to work. I need to go into > a created subdirectory=2C move the files in there to the parent directory= =2C > go back into the parent directory and remove the subdirectory. This is > all part of a graphic workflow I'm working on. >=20 > There is only one subdirectory created here=2C no more. >=20 > Dir.chdir("T:/asura/ads_books/out/tiff") > list =3D Dir.entries('.') > list.delete(".") > list.delete("..") >=20 > list.each do |dir| > Dir.chdir("T:/asura/ads_books/out/tiff/#{dir}") > Dir.glob("*.tiff").each do |tifffile| > FileUtils.mv(tifffile=2C "T:/asura/ads_books/out/tiff") > end > Dir.chdir("T:/asura/ads_books/out/tiff") > FileUtils.rm_rf('#{dir}') > end >=20 > Thank you=2C > Peter >=20 > --=20 > Posted via http://www.ruby-forum.com/. >=20 = --_ffde6853-e3d1-49ee-860c-6ff9fb61acad_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Take a look at a lesson on oldki= ngjames.org FilUtils is used to delete directory even with files inside.
> Date:=3B Thu=2C 29 Nov 2012 22:=3B39:=3B52 +=3B0900
>= From:=3B lists@=3Bruby-forum.com
> Subject:=3B removing direct= ories
> To:=3B ruby-talk@=3Bruby-lang.org
>
> Hello=2C
>= I'=3Bve googled around and I'=3Bve discovered that "=3BFileUtils.= rm_rf(=3B'=3B#=3B{=3Bdir}=3B'=3B)=3B
> will remov= e a directory. But=2C I can'=3Bt get it to work. I need to go into
> = a created subdirectory=2C move the files in there to the parent directory= =2C
> go back into the parent directory and remove the subdirectory. Thi= s is
> all part of a graphic workflow I'=3Bm working on.
>
> T= here is only one subdirectory created here=2C no more.
>
> Dir.chdir= (=3B"=3BT:=3B/asura/ads_books/out/tiff"=3B)=3B
> list = 1=3B Dir.entries(=3B'=3B.'=3B)=3B
> list.delete(=3B"= =3B."=3B)=3B
> list.delete(=3B"=3B.."=3B)=3B
>
= > list.each do |=3Bdir|=3B
> Dir.chdir(=3B"=3BT:=3B/a= sura/ads_books/out/tiff/#=3B{=3Bdir}=3B"=3B)=3B
> Dir= .glob(=3B"=3B*=3B.tiff"=3B)=3B.each do |=3Btifffile|= =3B
> FileUtils.mv(=3Btifffile=2C "=3BT:=3B/asura/ads_books= /out/tiff"=3B)=3B
> end
> Dir.chdir(=3B"=3BT:=3B/a= sura/ads_books/out/tiff"=3B)=3B
> FileUtils.rm_rf(=3B'=3B&= #35=3B{=3Bdir}=3B'=3B)=3B
> end
>
> Thank you=2C> Peter
>
> --
> Posted via http:=3B//www.ruby-forum.com/.>
= --_ffde6853-e3d1-49ee-860c-6ff9fb61acad_--