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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy in VBS

Status
Not open for further replies.

GarAng

IS-IT--Management
Jun 14, 2002
23
GB
Hi
I'm new to scripting,
Is it possible to write a script that will refer to a .txt file that has names and locations of file that need to be copied?

thanks

Gary
 
Yes.

Look at my FAQ for samples of how to read a text file and take action with the content. faq329-4871

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Many thanks
it's a start, but I'm still having trouble with the code to access the file

for example
If the ref file is c:\backups\ref_file.txt

looks like this
C:\GA\report\New Text Document.txt
C:\GA\report\New Text Document (2).txt
C:\GA\report\New Text Document (3).txt

how can i copy the file listed to a alternative location??

thanks
 
What have YOU tried so far and where in YOUR code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
To be honest, I'm not even sure if I'm even starting in the right area
Was looking at something like this

set Cfg = fso_OpenTextFile ("ref_list.txt")
do while not Cfg.AtEndOfStream
str = RTrim(Cfg.ReadLine)
fso.CopyFile str, fso.BuildPath("C:\backups\ref_list.txt"), ("C:\backups"

fso.GetFileName(str)) True
loop
 
OK got it
Spelling error in txt file


Public fso
set fso = CreateObject("Scripting.FileSystemObject")
set Cfg = fso_OpenTextFile("c:\report\ref_list.txt")
do while not Cfg.AtEndOfStream
str = RTrim(Cfg.ReadLine)
fso.CopyFile str, fso.BuildPath("C:\backups",fso.GetFileName(str)), True
loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top