Don's new functionality for <getdrop> introduced in version 12.10.0002 gave me an idea on using it for copying files to external drives, like flash/external hard drives. I find myself doing that more and more lately to copy to other computers when my home network isn't the ideal way to go. There's an example of <getdrop> and the use of self("caption") in the help file under "self". I also was able to take advantage of Don's new undocumented caller("caption") similar to "self". It was discussed in this thread (PeterH's suggestion), http://www.xyplorer.com/xyfc/viewtopic. ... on+#p80846 It's actually kind of slick, since it saved me from having to use a variable after each label heading to establish the different folder locations. This will come in very handy in other scripts.
Anyway, I wanted to have a menu listing a number of different folder locations (or I suppose it could be different drives also) on the flash drive/external drive - choices to drop the files. It's a pain in the you-know-what sometimes to have to scroll down the tree to get to those external drives. I've been testing this by dropping files on the script itself (thanks Don) and it works fine, but I'll probably end up putting in a catalog item since we can't drop on a CTB (yet).
By the way Don, I noticed that "gettoken" would not work properly to trim more than one space (using "t" in formating option) when the separator was a special character (e.g., like a bullet symbol). I had to use only one space (It worked fine if I used a normal "-" with 2 spaces on each side as I did below. You need a nice built-in download icon (i.e., down arrow).
Code: Select all
"_Initialize"
perm $Flash_Folder, $Rem_Dr;
$Rem_Dr = get("drives", 2), "|");
$Dr_Cnt = gettoken($Rem_Dr, "count", "|");
end $Dr_Cnt < "1", "You have no removable drives on-line, aborting!";
if ($Dr_Cnt > "1") {
status "You have more than one flash or external hard drive on-line!";
$Rem_Dr = inputselect("Select the Target Drive: <crlf>","$Rem_Dr", | ,4, ,350, 250, "Target Drive Selection");}
"Select Flash Drive Folder|:wipe"; //Don to test add, load self(file); or load *; obviously get rid of the first ;
"-"
" $Rem_Dr&";
sub _drop_it;
" $Rem_Dr&AHK";
sub _drop_it;
" $Rem_Dr&Downloads";
sub _drop_it;
" $Rem_Dr&Misc";
sub _drop_it;
" $Rem_Dr&XY";
sub _drop_it;
"_drop_it";
if (<get drop |> == ""){
status "Nothing to do" , , "alert";
}
else {
$Flash_Folder = ($Rem_Dr . gettoken(caller("caption"), -1, "&", "t"));
if (exists($Flash_Folder) >= 1) {
copyto $Flash_Folder, <get drop |>;
}
else {
msg "This path doesn't exist!";
}
}
"_Terminate"
unset $Flash_Folder; unset $Rem_Dr;
Ken
Edit: I made some tweaks to recognize the possibility of more than one flash or external hard drive, and if that's the case, allow you to select which one before selecting the folder to which we'll copy the file(s). Thanks highend for your example. It helped me greatly improve my initial version.
XYplorer Beta Club