VBscript FSO.MoveFolder failing when not hard coded
Posted on 2006-10-24
I'm trying to tidy up some folder names with a vbscript.
e.g. rename folder 'msgid_123456_Filename_date_version' to 'Filename date version'
I've done all the tidying and have two variables with the before and after folder names in.
If I run the code:
objFSO.MoveFolder "c:\msgid_123456_Filename_date_version" , "C:\Filename date version"
It works fine and renames the folder no problem.
If I try to use variables it seems to fail: I've tried several ways
strBefore = "'" & strBefore & "'"
strAfter = "'" & strAfter & "'"
strBefore = chr(34) & strBefore & chr(34)
strAfter = chr(34) & strAfter & chr(34)
As soon as I try to use variables with the movefolder command I get "Bad filename or number" error message on the movefolder line
Also if echo strBefore and strAfter on the screen they are exactly as I want them and definately point the correct folders with no spelling mistakes.
Does anyone have any ideas??