Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Does anybody know of an sync app that can produce symbolic links rather than copying the files? Or what would a (Windows) batch script look like that does this?

If a script is the solution, I want to recursively search a folder tree for folders with a certain name, like 'My Folder', and only 'sync' (create links to) those folders.

share|improve this question
2  
What exactly are you trying to achieve? It sounds like you may be going about it the wrong way. –  jcrawfordor Sep 9 '11 at 2:38
1  
I'm trying to achieve creating a set of symbolic links to a bunch of folders automatically. What is wrong with that? It's because I want to store certain user created app specific files (like presets) in one location along with other personal files. But I need the symbolic links so the programs will see them. But whenever I upgrade or re-install these programs I will have to re-create these links. I'm just trying to deal with the messy way that Windows and these apps store such files. –  Moss Sep 9 '11 at 5:37

2 Answers 2

up vote 1 down vote accepted

So I learned me some cmd scripting and here is what I came up with:

SET target="M:\TEST"
SET filter="Personal"

forfiles /s /m %filter% /c "cmd /c IF @isdir==TRUE mkdir %target%\@relpath"
forfiles /s /m %filter% /c "cmd /c IF @isdir==TRUE rmdir %target%\@relpath"
forfiles /s /m %filter% /c "cmd /c IF @isdir==TRUE mklink /D %target%\@relpath %cd%\@relpath"

That will look for all folders called "Personal" in the current directory and make symlinks in the target directory. I had to do some trickery in order to preserve folder structure. (It didn't want to create symlinks in locations that didn't exist yet.)

It may be convoluted but so are the programs I am trying to manage (FL Studio in this case).

UPDATE

That code ran into problems when there were spaces in the paths. Many hours of madness later, here is what seems to work. Yes there are lots of quotes.

SET target=C:\Program Files\Path With Spaces
SET filter=Personal

forfiles /s /m %filter% /c "cmd /c IF @isdir==TRUE mkdir """%target%"""\@relpath"
forfiles /s /m %filter% /c "cmd /c IF @isdir==TRUE rmdir """%target%"""\@relpath"
forfiles /s /m %filter% /c "cmd /c IF @isdir==TRUE mklink /D """%target%"""\@relpath """%cd%"""\@relpath"
share|improve this answer
1  
Yup, you have to triple quote paths with spaces in batchfiles. –  surfasb Sep 12 '11 at 9:32

xxcopy has over 230 switches, some of which are for symlink handling, as discussed here.

It can sync your symlinks. There is a free version for personal use, but it is no good for automated scripting, as it needs user input (pressing Y for OK).

XXCOPY

share|improve this answer
    
Cool. Don't really need it for now but I will keep it in mind! –  Moss Sep 13 '11 at 0:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.