Windows: Sync network share with softlinks to make it indexable for Windows Search


Recommended Posts

Indexed Searching on network shares works only if:

 

The implementation of the Windows Search Protocol in Linux' Samba is still in development:

https://lists.samba.org/archive/samba/2020-April/229273.html Last Statement I found

https://github.com/noelpower/samba/tree/WSP-WIP-4.11 Project

 

So I came up with this simple windows batch script, which syncs locally the target share by creating softlinks (which allows only indexed searching for filenames and not size or content):

SET target="C:\Users\<your_username>\unraid\sharename"
SET source="\\tower\sharename"
PushD %source% &&(
    forfiles -s -c "cmd /c IF @isdir==TRUE mkdir ""%target%""\@relpath"
    forfiles -s -c "cmd /c IF @isdir==FALSE mklink ""%target%""\@relpath ""%source%""\@relpath"
) & PopD

 

Simply paste it into a file like softsync.bat and execute it as admin.

 

Source (network share):

image.png.79dd3087e2673d33f3c8a8abccefae3e.png

 

Target (local):

image.png.bdda0afca4413accfc7bcf7a55ad86e3.png

 

Search result:

1059627018_2021-08-0813_00_54.png.d2903455675afb074c2af4152b784bb0.png

 

Note:

Its a one-way sync. This means if files are deleted on the network share the symlink still exists. You could delete the local folder content at the beginning of the script, if you like to cover deleted files as well.

 

Sources:

https://superuser.com/a/210957/129262

https://superuser.com/a/333863/129262

https://stackoverflow.com/a/8714962/318765

https://docs.microsoft.com/de-de/windows-server/administration/windows-commands/forfiles

https://docs.microsoft.com/de-de/windows-server/administration/windows-commands/mklink

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.