As part of a much larger VB macro I am trying to add an instruction through a VB script to rename a file without recourse to the rename dialog
The script creates two variables oldname and newname
Each, obviously takes a form like: E:\Imaging\Photographs\Spares\myfile.jpg
So I need to construct
ClickData.Func.Command.AddLine("RENAME oldname TO newname")
Whatever I do I can never get the command to work. The usual error from Windows is that "Windows cannot find the file "
I am sure that this is because I need some quotes around the variables in the statement as there are spaces in the variables. But I simply cannot work out how many quotes I need and where to put them.
Can anyone help?
Can I change the focus of this question. Having finally managed to work out the quotes:-
ClickData.Func.Command.AddLine("RENAME FROM "" & totfile TO "" & dopple """"")
I am left with one problem. The rename dialog box keeps appearing. How can I prevent this from happening, please?
If that's your actual command line pasted verbatim, the quotes are still wrong and will definitely cause problems.
ClickData.Func.Command.AddLine("RENAME FROM """ & totfile & """ TO """ & dopple & """")
Can you point me in the direction of some documentation to help me sort this quotes businerss out once and for all, please? I have scoured the help files for hours without success.
Googling how do quotes work in vbscript gets you lots of answers.
This is the second one which looks good:
At last, an explanation even I can understand. And what's more it works. I have my script working perfectly, now. I am much obliged.