keith li
asked on
Microsft VBScript error: file already exist
Dear All
I have below vbscript created and run in window task manager, and it works well for a week, and start from yesterday i,m getting "microsoft VBScript runtime error: File already exist" , any idea ?
With CreateObject("Scripting.Fi leSystemOb ject")
.MoveFile "\\10.154.105.100\Upload from OC\*.*", "\\10.141.101.60\test"
End With
Keith
I have below vbscript created and run in window task manager, and it works well for a week, and start from yesterday i,m getting "microsoft VBScript runtime error: File already exist" , any idea ?
With CreateObject("Scripting.Fi
.MoveFile "\\10.154.105.100\Upload from OC\*.*", "\\10.141.101.60\test"
End With
Keith
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hmm, "Kill" is not "checking"...
ASKER
Yes I found the file with same name exist the target location, but I have another 3 scripts to run different source, but all of them show file name exist, and I'm sure in the target folder don't have the same file name, anyway I will try to use the script in the previous post, and what does it mean if "kill" is not "checking" ?
The kill instruction delete the file given in parameter.
The question I would ask is what do you want to happen when the file already exists?
»bp
- Copy and overwrite?
- Do not copy?
- Other...?
»bp
ASKER
overwrite it i want
ASKER
i,m getting "microsoft vbscript compliation error: expected end of statement. can help to check where went wrong ?
dim fso
set fso = CreateObject("Scripting.Fi leSystemOb ject")
dim folder
set folder = fso.getFolder "\\10.154.104.101\Upload from FS\*.*"
dim file
for each file in folder.files
dim Path
path = "\\10.141.101.60\test" & file.name
if (fso.fileExists(path)) then
kill path
end if
fso .MoveFile "\\10.154.104.101\Upload from FS\*.*" & file.name, path
next
dim fso
set fso = CreateObject("Scripting.Fi
dim folder
set folder = fso.getFolder "\\10.154.104.101\Upload from FS\*.*"
dim file
for each file in folder.files
dim Path
path = "\\10.141.101.60\test" & file.name
if (fso.fileExists(path)) then
kill path
end if
fso .MoveFile "\\10.154.104.101\Upload from FS\*.*" & file.name, path
next
Not sure about the compilation error, but don't make mistakes when you copy / paste code, the "select all" option is here for this purpose.
path = "\\10.141.101.60\test" & file.nameYou missed an "\"
fso .MoveFile "\\10.154.104.101\Upload from FS\*.*" & file.name, pathRemove "*.*"