From: Alexander McMillan Date: 2012-12-01T01:43:50+09:00 Subject: Re: removing directories --_544d4d59-ebdf-4cdc-a68f-93dad68a798f_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable require 'fileUtils' # And now the code to delete the directory tree. =20 FileUtils.remove_dir("C:/Users/your/filepath/to_directory") To can read this lesson 27 @=20 http://www.oldkingjames.org/RUBY_LESSONS/ruby_lessons_index.html > 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 = --_544d4d59-ebdf-4cdc-a68f-93dad68a798f_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
require '=3BfileUtils'=3B<= br># And now the code to delete the directory tree.

FileUtils.remov= e_dir("=3BC:/Users/your/filepath/to_directory"=3B)

To can re= ad this lesson 27 @
http://www.oldkingjames.org/RUBY_LESSONS/ruby_lesso= ns_index.html

> Date:=3B Thu=2C 29 Nov 2012 22:=3B39:=3B52 = +=3B0900
> From:=3B lists@=3Bruby-forum.com
> Subject:=3B= removing directories
> To:=3B ruby-talk@=3Bruby-lang.org
> > Hello=2C
> I'=3Bve googled around and I'=3Bve discovered that &= #34=3BFileUtils.rm_rf(=3B'=3B#=3B{=3Bdir}=3B'=3B)=3B=
> will remove 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 pa= rent directory=2C
> go back into the parent directory and remove the sub= directory. This is
> all part of a graphic workflow I'=3Bm working on= .
>
> There is only one subdirectory created here=2C no more.
> <= br>> Dir.chdir(=3B"=3BT:=3B/asura/ads_books/out/tiff"=3B)=3B=
> list ==3B Dir.entries(=3B'=3B.'=3B)=3B
> list.delet= e(=3B"=3B."=3B)=3B
> list.delete(=3B"=3B.."=3B)= =3B
>
> list.each do |=3Bdir|=3B
> Dir.chdir(=3B"= =3BT:=3B/asura/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&= #34=3BT:=3B/asura/ads_books/out/tiff"=3B)=3B
> FileUtils.rm_r= f(=3B'=3B#=3B{=3Bdir}=3B'=3B)=3B
> end
>
>= Thank you=2C
> Peter
>
> --
> Posted via http:=3B//www.ru= by-forum.com/.
>
= --_544d4d59-ebdf-4cdc-a68f-93dad68a798f_--