I'm having trouble renaming a file using dos_system.
My code is:
Old_File_Name = "UNIT COST SHEET (SCHEME OFT\-OEIC,EXPANDE.txt";
New_File_Name = "day01.txt";
Loc = getvar("result") & "\\Icon_Reports\\";
dos_system("rename \"" & Loc & Old_File_Name & "\" \"" & New_File_Name & "\"");
When the above runs it doesn't rename the file. But if I get WR to print everything within the dos_system brackets into notepad, after the above, the following is seen:
rename "C:\Program Files\Mercury Interactive\WinRunner\tmp\noname21\res1\Icon_Repor ts\UNIT COST SHEET (SCHEME OFT-OEIC,EXPANDE.txt" "day01.txt"
If I then copy it manually into a cmd prompt the rename works!
Any ideas how I can get around this please?
Try altering the contents of Old_File_Name.
You don't need to escape dashes in a string - that changes the file name from
UNIT COST SHEET (SCHEME OFT-OEIC,EXPANDE.txt
UNIT COST SHEET (SCHEME OFT\-OEIC,EXPANDE.txt
which will fail as it isn't the file you list in your manual command line.
Insanity: doing the same thing over and over again and expecting different results
Cheers for that Tony, problem solved. Another happy customer ;-)