Ok Don, I may have unearthed a bug here, but whether it is or it's a "feature" you'll be able to tell.
To reproduce:
1. Load the script file below through your UDC menu and assign a KS to it:
Code: Select all
"To All Selected Items... : ForEachItem"
// this script file
self $me, file;
// now turn the list of all selected items into a little script
regexreplace $script, getinfo("SelectedItemsPathNames", <crlf>), "(.+)\r\n", " copytext ""$1""; load ""$me"", ""_ForEachItem_moving""; ";
// and execute it
load $script,,s;
"_ForEachItem_moving"
// extract item's name
regexreplace $item, <clipboard>, "^.+\\(.+)$", "$1";
//
strpos $p, $item, "temp.try";
sub ($p > -1) ? "_moveFile" : "_nothing";
strpos $p, $item, "temp";
sub ($p > -1) ? "_moveFile2" : "_nothing";
"_moveFile"
moveto "d:\temp\", <clipboard>;
"_moveFile2"
moveto "d:\temp2\", <clipboard>;
"_nothing"
2. Create a file called temp.try.txt
3. Create the necessary dirs for a file to be moved to
4. Try applying the script to that file
The problem seems to be that pattern matching mechanism goes through the whole list of patterns before moving a file to the correct folder (as opposed to going for the first match it finds). This creates a clash in our example, which pops up a warning window saying the file could not be found and that certain part of the script has failed. My actual script has some refined sorting at the top of it to prevent incorrect sorting, which is necessary because wildcards aren't allowed here, but I still get a warning. At the very least, it's strongly undesired behaviour and should not happen.