Page 1 of 1

Script to copy a renamed copy of a file to a folder

Posted: 29 Jul 2019 11:07
by ryloth
Dear all,
I have a script that sends a copy of a file to a folder
$SelectedItems = get("SelectedItemsPathNames", "|"); copyto "C:\OLD.FILES", $SelectedItems;

Now I would like that the copied file (not the original) is renamed once in the destination folder so that the date is added to the file name.

Up to now I obtain this result by manually selecting the file
using this script:
::rename , '*.<datem yymmdd>'

Than copying the file
$SelectedItems = get("SelectedItemsPathNames", "|"); copyto "C:\OLD.FILES", $SelectedItems;

And finally manually removing the date to the original file.

Any chance to merge all these tasks into a single script?

Thank you

Re: Script to copy a renamed copy of a file to a folder

Posted: 29 Jul 2019 11:13
by highend

Code: Select all

    $dst = "C:\OLD.FILES";
    if (exists($dst) != 2) { new($dst, "dir"); }
    foreach($item, <get SelectedItemsPathNames |>, , "e") {
        if (exists($item) != 1) { continue; }
        copyitem $item, "$dst\*.<date yyyymmdd>.?";
    }