Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12201

How to Copy Files in Windows While Preserving Junction Links as Links?

$
0
0

I'm currently facing a challenge with copying files in Windows and retaining junction links as junction links instead of copying the contents they point to. Here’s the context:

I have three folders: Folder A, Folder B, and Folder C. Folder B contains different files but also a junction link that points to Folder A. I want to copy the contents of Folder B (which includes various files and subfolders, one of which is a junction link to A) into Folder C. The key requirement is that the junction link in Folder A should remain a junction link in Folder C, rather than being replaced by the actual data it points to.

I've attempted using PowerShell scripts and explored Robocopy with flags like /E /COPYALL /SL, but it results in copying the actual data referred by the junction link rather than copying the link itself. This approach unfortunately leads to data duplication across different disks, which is not desirable.

Here’s a brief outline of what I tried:

C:\Windows\System32\robocopy.exe "path\to\FolderA" "path\to\FolderC" /UNILOG:C:\Robocopy\Log\move.log /copyall /XD $RECYCLE.BIN "System Volume Information" /dcopy:t /E /TEE /NFL /NDL /MIR /XO /B /ZB /Z /R:5 /W:5 /NP /XJ /MT:96

The command copies everything, but expands the junction links to their target data, which duplicates content rather than simply linking to it.

I am looking for a solution that:

Copies all contents of Folder B to Folder C.

Preserves the junction link as a link in Folder C, without duplicating the linked data.Does anyone have insights on how to achieve this or could suggest a tool or method that respects the junction properties during the copy? Any help or pointers towards relevant tools or scripts would be greatly appreciated!

Thank you!


Viewing all articles
Browse latest Browse all 12201

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>