UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Copy Directory And Contents    
 
   
johnpdmccall
post Sep 18 2018, 09:32 AM
Post#1



Posts: 1,808
Joined: 14-March 00
From: Ayrshire, Scotland


Hi Folks,

I'm new to VBScript but like messing with VBA

I want to copy a directory and all of its files to another directory. If the directory doesn't exist I want it to be created.

I found the following code on Microsoft.com:

CODE
My.Computer.FileSystem.CopyDirectory("G:\AccdbBackUps1", "G:\AccdbBackUps2", True)



I pasted it into an empty Test.txt file and renamed the file Test.vbs


It's getting a compilation error.
Something tells me I need to have more in the test.vbs file :-)


--------------------
Cheers,
John
Go to the top of the page
 
DanielPineault
post Sep 18 2018, 01:06 PM
Post#2


UtterAccess VIP
Posts: 7,000
Joined: 30-June 11



See: https://www.vbsedit.com/html/3481a0bc-3fed-...3a53adfa0e1.asp

--------------------
Daniel Pineault (2010-2019 Microsoft MVP, UA VIP, EE Distinguished Expert 2018)
Professional Help: https://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: https://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
johnpdmccall
post Sep 18 2018, 04:10 PM
Post#3



Posts: 1,808
Joined: 14-March 00
From: Ayrshire, Scotland


Thanks Daniel, that's given me a place to start looking and learning. I've downloaded VbsEdit which has lots of helpful samples.

Here's what I used (just in case anyone else needs it):


CODE
' Copy a Set of Files

Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\FSO\*.txt" , "D:\Archive\" , OverwriteExisting

--------------------
Cheers,
John
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    9th December 2019 - 02:41 AM