windows 7 - Moving folders to another drive under Win7 using junction

26
2013-08
  • foosion

    I plan to install an msata SSD drive on my notebook to hold windows and programs, while keeping data files, the users directory, etc. on the old HD.

    It would be easier if I could continue to refer to the data files as c:\whatever, even though they are physically in d:\whatever.

    If I understand correctly, the best way is to create a junction, such as

    mklink /j d:\whatever c:\whatever
    

    Do I then just move the old directory and all its subdirectories to d:\whatever, using windows explorer or something from the command line? Or would create circularity problems?

    Windows7x64 Pro, if that matters.

  • Answers
  • surfasb

    I do exactly the same thing to move large data files from my SSD on C: to another hard drive.

    You need to move the folder first.

    Then, create a symbolic link (or junction if you prefer, in this case they provide the same functionality) from the original location to the destination location using the command:

    mklink /D OriginalLocation DestinationLocation
    

    The /D makes a symbolic directory link which can span volumes. (Edit: Junctions may also span volumes)

    Using Windows Explorer, you'll see a little shortcut icon on the folder of the original location. Using dir /a on the parent directory will show <SYMLINKD> in place of <DIR>.

  • contact us

    FAR Manager can create symlinks using Alt+F6, also the linked folders will be marked with <link> which makes it easier to spot them. Don't know about Windows 7, but in previous versions of Windows, using Explorer to delete a symlinked folder would lead to catastrophic results such as deleting the actual target folder.

    To alias files (not folders) you could use: fsutil hardlink create <new filename> <existing filename>.

    If FAR Manager is not good enough for you, then you could symlink folders with the junction command line utility by Mark Russinovich, e.g.:

    junction d:\symlinked_folder c:\winnt
    

    And no, you can't actually 'move a folder using junction', a junction is just an alias for another folder which the client applications would see as 'the real thing'.


  • Related Question

    windows 7 - How can I create a right click menu item to manipulate a junction point?
  • Tom Wijsman

    As I am using a SSD but it is limited in size I want to be able to use junction points to remap files and directories to my HDD, this would work ideal if I could create a shell extension for it that does this.

    The ideal behavior would be to right click a directory or junction point and have an option
    "Manipulate junction point" in which I can perform the following actions:

    • Create: For a directory, move the directory to a location I specify and replace it by a junction point.
      (Dir) C:\Example turns into (JP) C:\Example --> D:\Example

    • Swap: For a junction point, I want to swap the junction point with its location.
      (JP) C:\Example --> (Dir) D:\Example turns into (Dir) C:\Example <-- (JP) D:\Example

      This means it would remove the junction point, move the data and place a reverse junction point.

    • Remove: For a junction point, I want to remove it and move the directory back.
      (JP) C:\Example --> (Dir) D:\Example turns into (Dir) C:\Example

    My most important questions:

    • What approach should I take to do this? Script? Bash? Executable?
    • How do I create the menu entry?

    Less important questions:

    • Does there exist such a solution already?
    • Are there better commands or API calls for checking and manipulating junction points?

    I already know of Microsoft's mklink and Sysinternals junction.


  • Related Answers
  • Isxek

    Since you asked if such solutions exist already, have you taken a look at Junction Link Magic or Link Shell Extension?

    Junction Link Magic allows creation, modification, and removal of junction points. It is freeware, and does support Windows 7.

    Link Shell Extension also provides the same functionality, and is also freeware. It also supports Windows 7.

  • Randolph West

    I just use MKLINK which is built into Windows 7. You'll end up writing batch files I guess, but it's not hard to use.