Page 1 of 1

Variable resolving broken/unreliable in sc copyas?

Posted: 13 Sep 2013 22:40
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...

Re: Variable resolving broken/unreliable in sc copyas?

Posted: 14 Sep 2013 10:01
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;
    }

Re: Variable resolving broken/unreliable in sc copyas?

Posted: 14 Sep 2013 10:23
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)...

Re: Variable resolving broken/unreliable in sc copyas?

Posted: 14 Sep 2013 10:52
by admin
OK, added some boldness.