Replace file if smaller in size
- From: Southcoaster <olly120@xxxxxxxxx>
- Date: Thu, 20 Sep 2007 07:32:43 -0700
Am very new to vbscript and am trying to piece together some code that
will check the size of a file on a users Home drive and replace it
with a file from the C:\ drive if it is 3mb. Can one of the guru's in
the group put me right..
Thanks in advance...
______________________________
Option Explicit
On Error Resume Next
'
Dim FolderPath
Dim objFSO
Dim objFolder
Dim colFiles
Dim objFile
FolderPath = "H:\foldername"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("H:\foldername")
Set objFile = "file.txt"
'Check if user has folder or not
If CheckFolderExists("H:\foldername") Then
Else
End If
'Reference the file.txt file if exists
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("H:\foldername\file.txt") Then
Set objFolder = objFSO.GetFile("H:\foldername\file.txt")
Else
End If
'Conditional overwrite if file.txt if is less than 3 mb
If objFile.size > 3000 kb Then
objFSO.CopyFile "C:\program files\prog\folder" , "H:\folder",
OverwriteExisting
Else
End If
_____________________________
Wscript error says "expected "then" on this line
If objFile.size > 3000 kb Then
.
- Follow-Ups:
- Re: Replace file if smaller in size
- From: Southcoaster
- Re: Replace file if smaller in size
- From: Pegasus \(MVP\)
- Re: Replace file if smaller in size
- Prev by Date: Re: update table with the word Null
- Next by Date: Re: update table with the word Null
- Previous by thread: update table with the word Null
- Next by thread: Re: Replace file if smaller in size
- Index(es):
Relevant Pages
|