30
Sep/09
0

Move Files from a Folder via script

This VBScript moves Files (and only Files!) from one to another directory.

1
2
3
4
5
6
7
8
9
10
11
12
13
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
sSourceFolder = "C:\Temp1"
sDestinationFolder = "C:\Temp2"
 
For Each sFile In objFSO.GetFolder(sSourceFolder).Files
	If objFSO.FileExists(sDestinationFolder & "\" & objFSO.GetFileName(sFile)) Then
		WScript.Echo "Deleting File:" & sDestinationFolder & "\" & objFSO.GetFileName(sFile)
		objFSO.GetFile(sDestinationFolder & "\" & objFSO.GetFileName(sFile)).Delete
	End If
	WScript.Echo "Moving : " & Chr(34) & objFSO.GetFileName(sFile) & Chr(34) & " to " & sDestinationFolder 
	objFSO.GetFile(sFile).Move sDestinationFolder & "\" & objFSO.GetFileName(sFile)  
Next
Print This Post
(3 votes, average: 5.00 out of 5)
Loading ... Loading ...
294 views