[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby nooby

anthony

2/23/2009 12:29:00 AM

I am clueless. Mostly.

I program phone switches for a living.

I have lots of data images for multiple platforms.

The information of interest will be the file extension and perhaps the
date/time stamp.

I want to write a script that will go through my BACKUPS folder and do
the following:

1. Create folders for each platform in some arbitrary location, if the
folders already exist then gracefully move on.

2. Copy data image files by extension into the appropriate newly created
folders.

3. Sort the files that now exist in the newly created folders by date,
preferably by month.


Much thanks in advance.

At present, I go through the BACKUP folder once a month and manually
select the files I need and sort them out. Once done I copy them to my
manager for safe keeping on the office server.


Anthony
2 Answers

David Masover

2/23/2009 1:39:00 AM

0

anthony wrote:
> I want to write a script that will go through my BACKUPS folder and do
> the following:
>
> 1. Create folders for each platform in some arbitrary location, if the
> folders already exist then gracefully move on.
>
> 2. Copy data image files by extension into the appropriate newly created
> folders.
>
> 3. Sort the files that now exist in the newly created folders by date,
> preferably by month.
>
>
> Much thanks in advance.

Was there a question in there somewhere?

7stud --

2/23/2009 4:50:00 AM

0

anthony wrote:
> 1. Create folders for each platform in some arbitrary location, if the
> folders already exist then gracefully move on.
>

File.exist?()
Dir.mkdir()

> 2. Copy data image files by extension into the appropriate newly created
> folders.
>

require 'fileutils'

FileUtils::cp(src, dest, {:verbose => true, :preserve => true})


> 3. Sort the files that now exist in the newly created folders by date,
> preferably by month.

Dir.glob()
Enumerable#sort_by
File.new()
File#mtime



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