paddy086
asked on
.vbs copy files from folder to new folder plus extra coding
Hi have this vbs script that copies from a folder on c:\installfiles\ to c:\testfolder\htfolder\
This script works.
But I need help
1 what if I don’t know the source of the folder I know its folder called installfiles but let’s say I have it on a cd or usb key how can I get over the drive letter.
2 when the script is running it keeps getting you to click ok as it installs each file is there a way to just do this at the end of the script.
3 The script dose not copy over folders it just copies .txt .vbs .mp3 and so on it does not copy folders
I think once we will get this far I will close the question and open a new one for more thanks for your help people
This script works.
But I need help
1 what if I don’t know the source of the folder I know its folder called installfiles but let’s say I have it on a cd or usb key how can I get over the drive letter.
2 when the script is running it keeps getting you to click ok as it installs each file is there a way to just do this at the end of the script.
3 The script dose not copy over folders it just copies .txt .vbs .mp3 and so on it does not copy folders
Dim sOriginFolder, sDestinationFolder, sFile, oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
sOriginFolder = "c:\installfiles\"
sDestinationFolder = "c:\testfolder\htfolder\"
For Each sFile In oFSO.GetFolder(sOriginFolder).Files
If Not oFSO.FileExists(sDestinationFolder & "\" & oFSO.GetFileName(sFile)) Then
oFSO.GetFile(sFile).Copy sDestinationFolder & "\" & oFSO.GetFileName(sFile),True
WScript.Echo "Copying : " & Chr(34) & oFSO.GetFileName(sFile) & Chr(34) & " to " & sDestinationFolder
End If
Next
I think once we will get this far I will close the question and open a new one for more thanks for your help people
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
you will need a function that grabs destination folder and copies all files and directories recursively
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks that worked
I figured out question 1
If I create a folder let’s say test1 and I put my script and the installfiles folder into it then all I need to do is get the script to look at its own destination for the folder installfiles
original script line sOriginFolder = "c:\installfiles\"
new script line sOriginFolder = "installfiles\"
I figured out question 1
If I create a folder let’s say test1 and I put my script and the installfiles folder into it then all I need to do is get the script to look at its own destination for the folder installfiles
original script line sOriginFolder = "c:\installfiles\"
new script line sOriginFolder = "installfiles\"
actually just use:
Dim sOriginFolder, sDestinationFolder
Set fso = CreateObject("Scripting.FileSystemObject")
sOriginFolder = "c:\installfiles\*"
sDestinationFolder = "c:\testfolder\htfolder\"
fso.CopyFolder sOriginFolder, sDestinationFolder