Can I create directories with dynamic names on run time using Ruby1.9?

I have to download files from the web over several requests. The
downloaded files for each request have to be put in a folder with the
same name as the request number.

For example:

My script is now running to download files for request number 87665. So
all the downloaded files are to be put in the destination folder Current
Download\Attachment87665. So how do I do that?

Destination folder: Current Download is fixed. only need to create
Attachmentxxxxxx dynamically, where xxxxxx any request number.

This is Python version of code: but I want it in a Ruby, just for your
reference to understand what I am looking for

request_number = 82673

# base dir
_dir = "D:\Current Download"

# create dynamic name, like "D:\Current Download\Attachment82673"
_dir = os.path.join(_dir, 'Attachment%s' % request_number)

# create 'dynamic' dir, if it does not exist
if not os.path.exists(_dir):
    os.makedirs(_dir)

···

--
Posted via http://www.ruby-forum.com/.

Quoting Arup Rakshit (lists@ruby-forum.com):

My script is now running to download files for request number 87665. So
all the downloaded files are to be put in the destination folder Current
Download\Attachment87665. So how do I do that?

Function FileUtils#mkdir_p makes sure that all intermediate
directories are created when creating a path.

Carlo

···

Subject: Can I create directories with dynamic names on run time using Ruby1.9?
  Date: Thu 10 Jan 13 04:46:05PM +0900

--
  * Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe
  * di parlare tanto di amore e di rettitudine? (Chuang-Tzu)

Carlo E. Prelz wrote in post #1091698:

Subject: Can I create directories with dynamic names on run time using
Ruby1.9?
  Date: Thu 10 Jan 13 04:46:05PM +0900

Quoting Arup Rakshit (lists@ruby-forum.com):

My script is now running to download files for request number 87665. So
all the downloaded files are to be put in the destination folder Current
Download\Attachment87665. So how do I do that?

Function FileUtils#mkdir_p makes sure that all intermediate
directories are created when creating a path.

Carlo

Can I have a simple `snippet` for that, I am totally new to Ruby. I have
Ruby 1.9.3 installed in my PC(windows 7)

···

--
Posted via http://www.ruby-forum.com/\.

require 'fileutils'

path = "string to the folder"
FileUtils.mkdir_p(path)

···

-----
Carlos Agarie

Control engineering
Polytechnic School, University of São Paulo, Brazil
Computer engineering
Embry-Riddle Aeronautical University, USA

2013/1/10 Arup Rakshit <lists@ruby-forum.com>

Carlo E. Prelz wrote in post #1091698:
> Subject: Can I create directories with dynamic names on run time using
> Ruby1.9?
> Date: Thu 10 Jan 13 04:46:05PM +0900
>
> Quoting Arup Rakshit (lists@ruby-forum.com):
>
>> My script is now running to download files for request number 87665. So
>> all the downloaded files are to be put in the destination folder Current
>> Download\Attachment87665. So how do I do that?
>
> Function FileUtils#mkdir_p makes sure that all intermediate
> directories are created when creating a path.
>
> Carlo

Can I have a simple `snippet` for that, I am totally new to Ruby. I have
Ruby 1.9.3 installed in my PC(windows 7)

--
Posted via http://www.ruby-forum.com/\.

Quoting Arup Rakshit (lists@ruby-forum.com):

Can I have a simple `snippet` for that, I am totally new to Ruby. I have
Ruby 1.9.3 installed in my PC(windows 7)

You may be new to ruby, but in order to write code you should know how
to call a method of a class...

This works on Linux (I have no windows):

require 'fileutils'
FileUtils::mkdir_p('/a/b/c/d')

This results (if you have the appropriate rights) in the creation of
these directories:

/a
/a/b
/a/b/c
/a/b/c/d

Carlo

···

Subject: Re: Can I create directories with dynamic names on run time using Ruby1.9?
  Date: Thu 10 Jan 13 04:55:12PM +0900

--
  * Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe
  * di parlare tanto di amore e di rettitudine? (Chuang-Tzu)

Carlos Agarie wrote in post #1091700:

require 'fileutils'

path = "string to the folder"
FileUtils.mkdir_p(path)

-----
Carlos Agarie

Control engineering
Polytechnic School, University of So Paulo, Brazil
Computer engineering
Embry-Riddle Aeronautical University, USA

have you watched my `Python` snippet? Look at that how it is
concatenating and checking if that file exist or not? then dynamically
creating the folders with that name.

···

2013/1/10 Arup Rakshit <lists@ruby-forum.com>

--
Posted via http://www.ruby-forum.com/\.