Forum: Ruby Re: Questions about copying using FileUtils

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.
6087a044557d6b59ab52e7dd20f94da8?d=identicon&s=25 Peña, Botp (Guest)
on 2006-04-21 03:08
(Received via mailing list)
Peter Bailey wrote last Thursday, April 20, 2006 10:42 PM:

# As a related question, do all iterators, like my "each"
# below, require an "end?"

maybe we ask first "what is a block?" :)

# Dir.chdir("c:/scripts/ruby/temp")
# require 'fileutils'
# include FileUtils::Verbose
# psfiles = Dir.glob('*.ps')
# psfiles.collect!{ |psfile| File.basename(psfile, '.ps') }
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lose this line. you do not really need it ;)

# psfiles.each do |psfile|
#     puts psfile
#     FileUtils.cp("psfile", psfile + ".pageinfo")
                   ^^^^^^^^^
lose the quotes ;)
thus, your copy will look like sample.ps.pageinfo. I prefer this one so
i can trace where my backups/copy came from originally (and it resolves
duplicate basenames, too)

# end

kind regards -botp
This topic is locked and can not be replied to.