Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

path not found error when trying to rename a file

Status
Not open for further replies.

Nashvegas

Programmer
Feb 15, 2002
7
US
I am trying to write a script that will do several things one of which is rename some files with the original name plus the date and time. I have looked at other posts on how to do this and believe my code to be exactly the same as some of those. I keep getting an error, "path not found" whenever I try to run the code. I have pasted the affected code below. I took it out of the bigger script trying to debug it.

Any help whatsoever will be greatly appreciated.

' VBScript source code
Dim FSO
Set FSO = CreateObject ("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("D:\Billing Collections\Recent")
ADATE = FormatDateTime(Now, VbShortDate) & ".pdf"
'
For Each File In Folder.Files
'If Len (File.Name) = 12 Then
FSO.MoveFile "D:\Billing Collections\Recent\" & (File.Name), "D:\Billing Collections\Recent\" & left(File.Name,6) & ADATE
Next
 
Hello Nashvegas,

The easiest way to see the problem is adding
Code:
wscript.echo FormatDateTime(Now, VbShortDate)
and you see the problem of "/" being considered as subfolder under fso. You have to replace it with something else, say by nothingness or "-" etc. I eliminate it in this revision.
Code:
' VBScript source code
Dim FSO
Set FSO = CreateObject ("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("D:\Billing Collections\Recent")
ADATE = replace(FormatDateTime(Now, VbShortDate),"/","") & ".pdf"
'
For Each File In Folder.Files
'If Len (File.Name) = 12 Then 
   FSO.MoveFile Folder.path & "\" & (File.Name), Folder.path & "\" & left(File.Name,6) & ADATE
Next
regards - tsuji
 
WOOHOO!!!! It works great! Thank you.

I used the debug tip also, that would have been a big help if I had known to do that.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top