Question about Moving/Renaming Files in VBScript
Posted on 2007-10-10
I have a VBScript coded to pull all TXT files from a specific directory, and move/rename them with a prepended "SD-" in front of the filename.
Here is the current VB code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
strCurrentFolder = "c:\HWM\MachineData"
Set objFolder = objFSO.GetFolder(strCurrentFolder)
For Each objFile In objFolder.Files
If UCase(Right(objFile.Path, 3)) = "TXT" Then
objFSO.MoveFile objFile.Path, "SD-" & objFile.Name
The problem is, the files are being moved to wherever my script is run from, and I want them moved to a specific path. I've went round and round, but it seems like when I have the specific destination path right, it breaks the move.
All help appreciated!