Quotes for a folder rename is driving me nuts

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Quotes for a folder rename is driving me nuts

Post 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

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Quotes for a folder rename is driving me nuts

Post 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.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Quotes for a folder rename is driving me nuts

Post 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

Post Reply