Page 1 of 1

Quotes for a folder rename is driving me nuts

Posted: 26 Jun 2012 15:34
by klownboy
Hi, I'm trying to run what should be a very simple script to rename a folder if it exists. The folder structure does have a space in the name, but not in the folder actually being renamed. I've been doing research and stepping through the script, but I'm getting the new name contains invalid characters over and over with way too many attempts at different quote combinations, single, double, triple, quadruple, and even the word quote with no luck. Any help would be greatly appreciated. The if exists below does return a "2". Here is part of the script.
$puzzle = "D:\Games\BrainsBreaker 5\Ken\";
if (exists($puzzle)) {
renameitem("D:\Games\BrainsBreaker 5\Puzzles\", $puzzle);
}
else {
status "Folder name D:\Games\BrainsBreaker 5\Puzzles already exists.";
}
Thanks,
Ken

Re: Quotes for a folder rename is driving me nuts

Posted: 26 Jun 2012 15:43
by SkyFrontier
klownboy wrote:Hi, I'm trying to run what should be a very simple script to rename a folder if it exists. The folder structure does have a space in the name, but not in the folder actually being renamed. I've been doing research and stepping through the script, but I'm getting the new name contains invalid characters over and over with way too many attempts at different quote combinations, single, double, triple, quadruple, and even the word quote with no luck. Any help would be greatly appreciated. The if exists below does return a "2". Here is part of the script.
$puzzle = "D:\Games\BrainsBreaker 5\Ken\";
if (exists($puzzle)) {
renameitem("D:\Games\BrainsBreaker 5\Puzzles\", $puzzle);
}
else {
status "Folder name D:\Games\BrainsBreaker 5\Puzzles already exists.";
}
Thanks,
Ken

Try
renameitem("Puzzles", $puzzle);
instead.

Re: Quotes for a folder rename is driving me nuts

Posted: 26 Jun 2012 16:05
by klownboy
Thanks SkyFrontier, it worked, but only after I removed the trailing backslash in the folder name as shown on the first line below. I guess I shouldn't have been using the entire directory structure in the new folder just the folder actually being renamed.
$puzzle = "D:\Games\BrainsBreaker 5\Ken";
if (exists($puzzle)) {
renameitem("Puzzles", $puzzle);
}
else {
status "Folder name already D:\Games\BrainsBreaker 5\Puzzles.";
}
Thanks again,
Ken