View Full Version : C++ Help/Question

09 September 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


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

09 September 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() if ARGV.size != 2

require 'fileutils'
require 'find'

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

Install ruby first (One click installer for windows, at ( Save this code to a file like copy.rb and run it from the console.

09 September 2005, 06:56 AM
like this? (

09 September 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...


CGTalk Moderation
09 September 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.