How to turn a file shortcut into a copy
-
Merelin
- Posts: 2
- Joined: 29 Dec 2011 22:23
How to turn a file shortcut into a copy
Hi there!
Is there a way to turn a file shortcut into a copy of the related file?
I just set up a little music library specially for dj sets but on half the way i decided to use real copys instead of file shortcuts so i can also edit the tracks without destroying the original file in my main music library.
I tried the search function but didnt get anything related to my problem.
Thanks
Melvin
Is there a way to turn a file shortcut into a copy of the related file?
I just set up a little music library specially for dj sets but on half the way i decided to use real copys instead of file shortcuts so i can also edit the tracks without destroying the original file in my main music library.
I tried the search function but didnt get anything related to my problem.
Thanks
Melvin
-
Marco
- Posts: 2354
- Joined: 27 Jun 2011 15:20
Re: How to turn a file shortcut into a copy
No. There could be a way via scripting, if that fits your needs (although I don't have much time at the moment).
At first I thought about hardlinks, but since you say you would use the copies for safety and preservation-of-the-original purposes consider the option ruled out.
At first I thought about hardlinks, but since you say you would use the copies for safety and preservation-of-the-original purposes consider the option ruled out.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]
Don sees all [cit. from viewtopic.php?p=124094#p124094]
-
Stefan
- Posts: 1360
- Joined: 18 Nov 2008 21:47
- Location: Europe
Re: How to turn a file shortcut into a copy
Hi Melvin, welcome.
Right-click a LNK file, then use submenu Shortcut Target and there "Copy Shortcut Target Item"
Unfortunately i can't find an command ID for this command to use this with an script.
And an try to use readfile() to get the target link from the LNK fails because readfile() stops at first found 0
Only step-by-step per file:Merelin wrote:Is there a way to turn a file shortcut into a copy of the related file?
Right-click a LNK file, then use submenu Shortcut Target and there "Copy Shortcut Target Item"
Unfortunately i can't find an command ID for this command to use this with an script.
And an try to use readfile() to get the target link from the LNK fails because readfile() stops at first found 0
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: How to turn a file shortcut into a copy
Property "LinkTarget":Stefan wrote:Hi Melvin, welcome.
Only step-by-step per file:Merelin wrote:Is there a way to turn a file shortcut into a copy of the related file?
Right-click a LNK file, then use submenu Shortcut Target and there "Copy Shortcut Target Item"
Unfortunately i can't find an command ID for this command to use this with an script.
And an try to use readfile() to get the target link from the LNK fails because readfile() stops at first found 0
text property("LinkTarget", <curitem>);
-
Stefan
- Posts: 1360
- Joined: 18 Nov 2008 21:47
- Location: Europe
Re: How to turn a file shortcut into a copy
There is a property LinkTarget ? Great findserendipity wrote:Property "LinkTarget":
Then it is possible indeed:
copyto "<curpath>", property("LinkTarget", <curitem>);
Script to walk through all files in current folder and copy the target
from all found *.lnk files to the current folder, if it not already exists:
Code: Select all
////Start at top:
sel 1;
while(1){
////Loop through all items:
if ("<curitem>"==""){break;}
////If current file has *.LNK extension:
if ( recase("<curext>", "lower") == "lnk" ){
////If target file not already exists in current folder:
$TargetFile = gettoken(property("LinkTarget", <curitem>), -1, "\");
if (exists( "<curpath>\$TargetFile") != 1 ){
////copy target file to current folder:
copyto "<curpath>", property("LinkTarget", <curitem>);
}
////Delete *.lnk file:
//delete [recycle=1], [confirm], [itemlist]
//delete 1, 1, "<curitem>";
}
sel "+1";
}
EDIT: more proper indention
Last edited by Stefan on 01 Feb 2012 17:19, edited 1 time in total.
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: How to turn a file shortcut into a copy
Don't mention Stefan. You help a lot around here, so its not a big deal. I just happened to have an old script to see all file properties which I often use but never shared. Anyway, I just posted it here.Stefan wrote:There is a property LinkTarget ? Great findserendipity wrote:Property "LinkTarget":![]()
Then it is possible indeed:
copyto "<curpath>", property("LinkTarget", <curitem>);
Script to walk through all files in current folder and copy the target
from all found *.lnk files to the current folder, if it not already exists:Thanks serendipity!Code: Select all
////Start at top: sel 1; while(1){ ////Loop through all items: if ("<curitem>"==""){break;} ////If current file has *.LNK extension: if ( recase("<curext>", "lower") == "lnk" ){ ////If target file not already exists in current folder: $TargetFile = gettoken(property("LinkTarget", <curitem>), -1, "\"); if (exists( "<curpath>\$TargetFile") != 1 ){ ////copy target file to current folder: copyto "<curpath>", property("LinkTarget", <curitem>); } ////Delete *.lnk file: //delete [recycle=1], [confirm], [itemlist] //delete 1, 1, "<curitem>"; } sel "+1"; }
http://www.xyplorer.com/xyfc/viewtopic. ... 261#p67261
-
Merelin
- Posts: 2
- Joined: 29 Dec 2011 22:23
Re: How to turn a file shortcut into a copy
Thanks a lot! You saved my day... literally!
-
eil
- Posts: 1875
- Joined: 13 Jan 2011 19:44
Re: How to turn a file shortcut into a copy
to not make a different topic, can someone please modify this script so that it doesn't copy targeted files, but show a list of all real pathes via "text"?
i thought that at least this i'll be able to do, but seems i'm still too bad at xy scripting.
i thought that at least this i'll be able to do, but seems i'm still too bad at xy scripting.
Win 7 SP1 x64 100% 1366x768|1900x1080
-
highend
- Posts: 14955
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: How to turn a file shortcut into a copy
You mean something like this?eil wrote:to not make a different topic, can someone please modify this script so that it doesn't copy targeted files, but show a list of all real pathes via "text"?
i thought that at least this i'll be able to do, but seems i'm still too bad at xy scripting.
Code: Select all
sel 1;
$LinkList = "";
while(1){
////Loop through all items:
if ("<curitem>"==""){break;}
////If current file has *.LNK extension:
if ( recase("<curext>", "lower") == "lnk" ){
////If target file not already exists in current folder:
$TargetFile = property("LinkTarget", <curitem>);
if (exists( "<curpath>\$TargetFile") != 1 ){
////copy target file to current folder:
// copyto "<curpath>", property("LinkTarget", <curitem>);
$LinkList = $LinkList . $TargetFile . <crlf>;
}
////Delete *.lnk file:
//delete [recycle=1], [confirm], [itemlist]
//delete 1, 1, "<curitem>";
}
sel "+1";
}
if($LinkList != "") {
text $LinkList;
}One of my scripts helped you out? Please donate via Paypal
-
eil
- Posts: 1875
- Joined: 13 Jan 2011 19:44
Re: How to turn a file shortcut into a copy
can't say 'cause i don't see the result of script's work, but this:what am i doing wrong?
To see the attached files, you need to log into the forum.
Win 7 SP1 x64 100% 1366x768|1900x1080
-
highend
- Posts: 14955
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: How to turn a file shortcut into a copy
Regarding the modifications to the original script:
Remove the if condition on the last lines. But: When $LinkList is empty, there is nothing to display....
Ofc I've tested it before and it works without errors (at least here).
Regarding your script:
Öh, if(""==""){break;}... The if condition will always be true, so your break; will always terminate the loop.
Remove the if condition on the last lines. But: When $LinkList is empty, there is nothing to display....
Ofc I've tested it before and it works without errors (at least here).
Regarding your script:
Öh, if(""==""){break;}... The if condition will always be true, so your break; will always terminate the loop.
One of my scripts helped you out? Please donate via Paypal
-
Stefan
- Posts: 1360
- Joined: 18 Nov 2008 21:47
- Location: Europe
Re: How to turn a file shortcut into a copy
Please be sure to have all lines indented at least by one blank at the start of the line.eil wrote:can't say 'cause i don't see the result of script's work, but this:what am i doing wrong?
If you copy the above script that is not given and you get the result you mentioned.
See Common questions, mistakes and pitfalls - Indent your code!
For those who post scripts (me included
please be sure to have at least two blanks in front of each line, because the forum eats always one.
I usually use even three or four.
-
highend
- Posts: 14955
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: How to turn a file shortcut into a copy
It was just a fast copy of the posted script, edit and post back ;(please be sure to have at least two blanks in front of each line, because the forum eats always one
Wouldn't it be better to change the forum's code then? It's not the users "fault"...
One of my scripts helped you out? Please donate via Paypal
-
eil
- Posts: 1875
- Joined: 13 Jan 2011 19:44
Re: How to turn a file shortcut into a copy
it wasn't my script, it was wrong copied yours modification.highend wrote:Regarding your script:
Öh, if(""==""){break;}... The if condition will always be true, so your break; will always terminate the loop.
shame on me.Stefan wrote:Please be sure to have all lines indented at least by one blank at the start of the line.
If you copy the above script that is not given and you get the result you mentioned.
See Common questions, mistakes and pitfalls - Indent your code!
For those who post scripts (me included):
please be sure to have at least two blanks in front of each line, because the forum eats always one.
I usually use even three or four.
now all works. thanks highend and Stefan.
Win 7 SP1 x64 100% 1366x768|1900x1080
XYplorer Beta Club