PDA

View Full Version : C++ Help/Question


specxor
09-05-2005, 02:46 PM
Hi, Guys, just wondering if someone could help me out or a least point me in the right the direction...

I need a console/batch program that can copy a text file to a folder and all of its sub directories.... In the past i have done this with a maxscript but that is not an option anymore!!

I hate flat out asking for stuff like this without making an attemp my self but in this instance due to time and next to zero knowledge of C++ or vbscript or whatever.... Its drving me nuts to because i can understand (thanx to my mxs experience) how this could be coded just not the syntax and compiling etc...

One of these days ill have to get hold of C book!!! No any good ones???

Thanx in advanced guys

Cheers
Dave


--I no this isnt a Graphics programming question but just thought you guys would be the ones to ask...

gga
09-05-2005, 09:56 PM
Don't do it in C. You'll just pull your hair out. Use a scripting language to do it.
Get a hold of ruby or python and code it with that. Here's a ruby script that should do what you want (if I understood correctly):

#!/bin/env ruby
def help
cmd = $0.sub(/.*\//, '')
puts <<"HELP"
#{cmd} - v0.1
Copy a file to a directory and all its subdirectories.
Usage is:
#{cmd} file directory
HELP
exit(1)
end

help() if ARGV.size != 2

require 'fileutils'
require 'find'

Find.find(ARGV[1]) { |path|
next unless File.directory?(path)
puts "Copying #{ARGV[0]} to #{path}"
FileUtils.cp(ARGV[0], path)
}


Install ruby first (One click installer for windows, at www.rubyforge.net (http://www.rubyforge.net/)). Save this code to a file like copy.rb and run it from the console.

Stevemeister
09-06-2005, 06:56 AM
like this?
copyfile.zip (http://oompa.rick-n-steve.com/copyfile.zip)

specxor
09-06-2005, 08:47 AM
Stevemeister You are now officaly my best friend, what a life saver.... and gga i think you right about ruby or python... I have some time coming up in afew weeks i think i might get in to it... The c++ freaks me out i understand the code,funtctions bits and peices except for the whole building/compiling part one day ill get around to it!

Once again thank you very very very much...

Cheers
Dave

CGTalk Moderation
09-06-2005, 08:47 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.