Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need VB code for a copy command

Status
Not open for further replies.

futbwal15

IS-IT--Management
Jan 12, 2007
38
US
Im looking to create some code in VB that i need to take a file from a main folder and have it automatically copy this file into all subsequent folders. any ideas?

a simple little program for this would be great.
 
i dont know what my folder destinations are becuase new folders are created regularly.
 
If you don't know where to copy the file to, how will your application know where to put it?

Ask the user where they want their file to go.


Have fun.

---- Andy
 
i know what root folder that the file is in. Its just that there are subsequent folders under the main folder that i need the file copied into. here is what i tried in a .bat file but didnt quite work:

@echo off
rem Copy File.txt to Folder 000-999
for %%a in (0 1 2 3 4 5 6 7 8 9) do for %%b in (0 1 2 3 4 5 6 7 8 9) do for %%c in

(0 1 2 3 4 5 6 7 8 9) do copy\file.txt\Folder%%a%%b%%c
 
I see, my mistake.

You need to investigate FileSystemObject (FSO). It will allow you to loop thru subfolders in given folder, then you can use FileCopy or its way of copy a file.


Have fun.

---- Andy
 
cool i appreciate the advice....one last thing however. is it possible to have code that can search and tell me what all is in a folder. so if i searched for my main folder to exist, i then would need a list of names for the subsequent folders
 
Probably.

Me, myself, I don't like FSO, but do your research (there is A LOT of info about FSO on the Net) and I am sure you will find more than you need.

Have fun.

---- Andy
 
.. Or use the DIR command (details on several threads in this forum, or in your VBHelp)

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top