Saturday, October 9, 2010

Windows 7 has directory symlinks! And they are a great way to work around Dropbox limitations!

Dropbox is moderately awesome. One of the remarkably rare pieces of software that "just works" (so far). Except they haven't implemented the sync any folder feature (vote here!) despite receiving 60k votes for it over an 11 month period :( This causes horribly mundane and annoying problems like:
  • I want to use P:\Dropbox as my sync folder; ok, works great!
  • I have a shared folder for Starcraft 2 replays so I get replays under P:\Dropbox\My Dropbox\SC2-Replay. 
  • Starcraft 2 doesn't look there; in order to have these replays show up for selection in the replays list I need to sync only the SC2-Replay directory into a subdirectory of the directory Starcraft 2 looks at 
    • That is, I want C:\Users\UserName\Documents\StarCraft II\Accounts\########\1-S2-1-######\Replays to sync with the same thing as P:\Dropbox\My Dropbox\SC2-Replay
I could just put the entire Dropbox folder under Starcraft 2 but that really isn't ideal. In XP we'd have a problem; NTFS only had junction points (ref) and it wasn't as easy as you might hope to create them. Luckily in Windows 7 (and Vista) we finally get directory symlinks (ref)! Always nice to learn something useful while trying to accomplish something frivolous like making watching game replays easier.

So, having found out directory symlinks are now available I figured I'd find out how to create one. The first way I found was perhaps not as easy as I'd hoped:

BOOLEAN WINAPI CreateSymbolicLink(
  __in  LPTSTR lpSymlinkFileName,
  __in  LPTSTR lpTargetFileName,
  __in  DWORD dwFlags
);

Luckily it turns out that Windows 7 also provide mklink.exe (Vista has it too; although new to me mklink.exe is old news to the world) to handle all your command prompt NTFS linking needs. You can even create directory junctions (ref) with it if so inclined! Plus Windows Explorer now handles deletion of a directory junction graciously - the files don't get deleted if you delete the junction directory expecting the original/other access point in the file system to stick around.

The mklink.exe arguments are nice and simple:

>mklink /?
Creates a symbolic link.

MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    specifies the new symbolic link name.
        Target  specifies the path (relative or absolute) that the new link
                refers to.

Somewhat curiously (at least to me) creating a directory junction to link up my Dropbox replay to the Starcraft 2 directory tree did not require elevated permissions but creating a directory symlink required me to run cmd.exe as admin. Apparently this is by design but it seems a bit odd; I would have thought a junction was a bigger deal than a symlink. Anyway, once running as admin the link creates as easily as one could hope:

C:\Users\Imaginary\Documents\StarCraft II\Accounts\########\1-S2-1-######\Replays\Multiplayer>mklink /D DropboxSymLink "P:\Dropbox\My Dropbox\SC2-Replay"
symbolic link created for DropboxSymLink <<===>> P:\Dropbox\My Dropbox\SC2-Replay

And now I can see the replays people drop into our shared Dropbox folder from within Starcraft 2; yay!

It may be a bit manual but until that Dropbox gets that external folders feature this is going to be very handy; I can have different parts of my Dropbox show up scattered all over my filesystem now!

10 comments:

antred said...

I know this 3 years after the fact, but I'm still amazed that it took Microsoft only 4 decades to catch up to the rest of the world! :)

Genuine Man Truck Parts said...

The valuable client base of BP Auto Spares India can avail from them a wide range of Engine and Transmission mountings that are made and manufactured in compliance with the standards of the industry. They are one of the highly acclaimed Man Spare Parts dealers in the country. Man Truck Parts

health said...

I have read your article, it is very informative and helpful for me. I admire the valuable information you offer in your articles. Thanks for posting it.

mycherrycreek
pubfilm
kerala epass
xvideostudio video editor apk free download for pc full version
How many teaspoons in a tablespoon
soundcloud dark mode

Maria Yang said...

Tradingzy Is The Best And Most Reliable Seo Company And Offers A Wide Variety Of Forex Search Engine Optimization Company , Including An Affordable Monthly Subscription Service, One-time Links, And Blog Comments. With Any Of These Services, You Can Be Assured That Your Site Will Rank Higher In The Search Engine Results Page And Receive An Influx Of Targeted Traffic.

Steven Cohen said...

Ecdp stock Overview: Stay ahead of the market with our live and real time stock market overview. Get all of your favorite stocks in one place, and get alerted to live news at the same time!

Unknown said...

Start Forex Brokerage is a comprehensive guide to deciding on the best Forex Brokers, Trading Costs and Fees. Find out which brokers offer the best value for money?

Unknown said...

If you have been looking for facts about what is forex seo and how it works, Then tradingzy is the best and most reliable place. becouse tradingzy is Digital Marketing agency focusing on Forex Seo.

periyannan said...

Thank you for your post. This is superb information. It is amazing and great to visit your site.
Biotech Internships | internships for cse students | web designing course in chennai | it internships | electrical engineering internships | internship for bcom students | python training in chennai | web development internship | internship for bba students | internship for 1st year engineering students

خدمات منزلية said...

تسليك مجاري
تنظيف منازل
مكافحة حشرات
تنظيف منازل
تنظيف منازل
مكافحة حشرات
تسليك مجاري
مكافحة حشرات
تنظيف منازل

TRADEVIX said...

this is very nice post thanks for sharingInstall UiPath

Post a Comment