Skip to content

Instantly share code, notes, and snippets.

@segilbert
Created July 30, 2015 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save segilbert/45f7f0266b46342519b9 to your computer and use it in GitHub Desktop.
Save segilbert/45f7f0266b46342519b9 to your computer and use it in GitHub Desktop.
A helper function to deep copy a folder from C:\ to D:\, delete the folder once copied and create a sysmlink.
REM
REM ** USE AT YOUR OWN RISK **
REM
REM robocopy command line options
REM https://technet.microsoft.com/en-us/library/Cc733145.aspx
REM
REM How to move C:\ProgramData Cache to save gigs of space
REM http://superuser.com/questions/455853/can-i-delete-the-the-folder-c-programdata-package-cache
REM
REM Windows 8 specific space savings review link below
REM http://www.hanselman.com/blog/GuideToFreeingUpDiskSpaceUnderWindows81.aspx
REM
REM A helper function to deep copy a folder from C:\ to D:\
REM delete the folder once copied and create a sysmlink.
REM Simply pass in the folder to move.
REM
REM Example:
REM call move.directory.cmd "\ProgramData\Package Cache"
REM
REM Robocopy Command Line Options:
REM /e - Copies subdirectories. Note that this option includes empty directories.
REM /j
REM /copyall - Copies all file information (equivalent to /copy:DATSOU).
REM /dcopy:dat - Copies directory file properties Data, Attributes, and Time.
REM /sl - Copies the symbolic link instead of the target.
REM /ndl - Specifies that directory names are not to be logged.
REM /move - Moves files and directories, and deletes them from the source after they are copied.
REM
REM To create a sysmlink use mklink windows command.
REM mklink /J oldpath newpath
REM
robocopy "C:%~1" "D:\- C -%~1" /e /j /copyall /dcopy:dat /sl /ndl /move
mklink /J "C:%~1" "D:\- C -%~1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment