Forum: Ruby ruby nooby

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.
31d80ca357e4274bdde98230889c338b?d=identicon&s=25 anthony (Guest)
on 2009-02-23 01:30
(Received via mailing list)
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
1bc63d01bd3fcccc36fb030a62039352?d=identicon&s=25 David Masover (Guest)
on 2009-02-23 02:40
(Received via mailing list)
anthony wrote:
> preferably by month.
>
>
> Much thanks in advance.

Was there a question in there somewhere?
54404bcac0f45bf1c8e8b827cd9bb709?d=identicon&s=25 7stud -- (7stud)
on 2009-02-23 05:50
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
This topic is locked and can not be replied to.