Page 1 of 1
Delete target of shortcut
Posted: 06 Feb 2016 00:26
by xynoob
I want to be able to select a bunch of shortcut files (.lnk) and delete both the shortcut and the target file. So I tried the following:
Code: Select all
foreach($filename, "<get SelectedItemsPathNames |>") {
$target = property("#ShortcutTarget", $filename);
delete $target;
delete $filename
}
The variable values all seem OK i.e. when it gets to "delete $target", it shows the actual target filename. But when I get confirmation for delete, it is for the shortcut only, not the target. What am I doing wrong... this seems it should be straightforward.
TIA
Re: Delete target of shortcut
Posted: 06 Feb 2016 06:09
by bdeshi
Hold on. The delete command in XYplorer has three parameters in a strict order.
::rtfm 'idh_scripting_comref.htm#idh_sc_delete'; wrote:Code: Select all
delete [recycle=1], [confirm], [itemlist]
You've actually completely skipped the first two params, therefore the command has no valid itemlist, and defaults to deleting the currently focused/selected file(s).
Use this script instead.
Code: Select all
foreach($filename, "<get SelectedItemsPathNames |>") {
$target = property("#ShortcutTarget", $filename);
delete 1, 1, $target; //all parameters must exist...
delete , , $filename; //...but they can be left empty
}
Or this one if you want less prompts.
Code: Select all
step;
foreach($filename, "<get SelectedItemsPathNames |>") {
$target = property("#ShortcutTarget", $filename);
if confirm("Delete these items?|$target|$filename",'|') {
delete 1, 0, $target;
delete 1, 0, $filename;
}
}
And: Welcome to the club!

Re: Delete target of shortcut
Posted: 06 Feb 2016 19:06
by xynoob
Doh! Thanks - works great after adding the mandatory parameters!