Paste Special : Folder Contents as Sym/HardLink ?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
bossi
Posts: 144
Joined: 30 Jul 2022 11:09
Location: Win11-latest, XYx64 latest, 4K@100%

Paste Special : Folder Contents as Sym/HardLink ?

Post by bossi »

Hey guys , how about creating Hardlinks/SymLinks for Folder[Contents] ?
Yes , Hardlinks are not allowed for directories.

I want to copy/paste an exact copy of the whole directory_tree and iterate over the files and create Symbolic Links for each.

the focus is on RENAMING destination files while keeping source files untouched.
before doing python maybe there is a better way to do this in XY , since it has already build in PasteSpecial commands , and the manual aproach suits me .

the nearest solution is BranchedView in Source -> Copy -> Paste Special: Symbolic Links.
but it flatens the Folder Structure ....

in short :
how to copy paste Folder Structure and create SymbolicLinks for all files in one go ?
To see the attached files, you need to log into the forum.

highend
Posts: 14926
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Paste Special : Folder Contents as Sym/HardLink ?

Post by highend »

You mean something like this?

You need to select the folder that you want to make a copy of and when asked enter the name of the destination folder (which is created on the same hierarchy...)

Code: Select all

    setting "BackgroundFileOps", 0;

    $selected    = <get SelectedItemsPathNames>;
    $cntSelected = gettoken($selected, "count", <crlf>);
    end ($cntSelected == 0 || $cntSelected > 1), "Nothing or more than one item selected, aborted!";
    end (exists($selected) != 2), "No folder selected, aborted!";

    $newFolder = trim(input("Name of new folder?", , "new folder"));
    end (!$newFolder), "No folder name given, aborted!";

    $subFolders = quicksearch("/d", $selected, , "s");
    $subFiles   = quicksearch("/f", $selected, , "s");

    foreach($folder, $subFolders, <crlf>, "e") {
        $dst = gpc($selected, "component", -2, 1) . "\" . $newFolder . replace($folder, $selected);
        if (exists($dst) != 2) { new($dst, "dir"); }
    }

    foreach($file, $subFiles, <crlf>, "e") {
        $dst = gpc($selected, "component", -2, 1) . "\" . $newFolder . replace($file, $selected);
        new($dst, "symlink", $file);
    }
One of my scripts helped you out? Please donate via Paypal

bossi
Posts: 144
Joined: 30 Jul 2022 11:09
Location: Win11-latest, XYx64 latest, 4K@100%

Re: Paste Special : Folder Contents as Sym/HardLink ?

Post by bossi »

Holy moly , thank you sir ! :appl: :party:
Seems like you wrote it on the fly ?
there was an unnecessary } bracket at the end

Post Reply