Variable resolving broken/unreliable in sc copyas?

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Variable resolving broken/unreliable in sc copyas?

Post by highend »

I have 4 files in the active pane:
Test.r00
Test.rar
Test.part1.rar
Test.part2.rar

and this little script:

Code: Select all

    $files = get("selectedItemsPathNames", "|");
    foreach ($file, $files, "|") {
        copyas "* <datem yyyy_mmdd>.?", get("Path", "i"), $file;
    }
Whenever I select only one file, the destination file will have the date variable as expected.

But if I e.g. select the first two, use the script (destination files are correct) and then select file 3+4 and run the script again, the destination files will be unmodified. If you don't get this behavior in the first place, select e.g. all 4 files, only 1, three (all with executing the script afterwards)...

If sc step; is used before the loop you'll see that the <datem ...> variable isn't always resolved.

Tried with the latest beta and /fresh switch...
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 67315
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Variable resolving broken/unreliable in sc copyas?

Post by admin »

You need to enclose the date variable in single quotes to get the modified date of each selected files. Otherwise you get the modified date of the currently focused and selected file (or no date if there is no focused and selected file).

Code: Select all

$files = get("selectedItemsPathNames", "|");
    foreach ($file, $files, "|") {
        copyas '* <datem yyyy_mmdd>.?', get("Path", "i"), $file;
    }

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Variable resolving broken/unreliable in sc copyas?

Post by highend »

Thanks,

mind to make a small note in the pattern description like:
Single or double quotes make a difference! Take a look at the last example for an explanation.

I've read the full description of the options but not every example (and I guess many users do
it in a similar way)...
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 67315
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Variable resolving broken/unreliable in sc copyas?

Post by admin »

OK, added some boldness.

Post Reply