3

I wish to move a folder that is located under Users folder in C drive to D drive in order to free up space. The folder is by my name and has things like pictures, downloads, documents, desktop, videos etc. so is it safe to do so?

OS: Windows 10 64-bit

2 Answers 2

1

One way to do this is to use the symbolic link.

Let's say your username is Rob and you want shift pictures to drive D.

  1. Got to the command line

  2. Type in mklink /D c:\users\Rob\newpictures d:\Rob\pictures

    This creates a new link on drive C to the folder on drive D.

  3. Go to drive D and create folders Rob and then Rob\pictures

  4. Create a file (any file) in D:\Rob\pictures

  5. Check on c:\users\Rob\newpictures, that you can see this new file.

    If you can, then the process is correct so far.

  6. Move all the files from c:\users\Rob\pictures to d:\Rob\pictures.

  7. Delete c:\users\Rob\pictures. If it wont let you then just rename pictures to oldpictures.

  8. Rename to c:\users\Rob\newpictures to c:\users\Rob\pictures

I have not used it to move files under Users, but it has worked for me for other folders.

1

Refer to this article dealing about Powershell – Script to move profile folders


# This command has 2 non-mandatory parametrs
# Parameter 1: User-Account -> f.e "user1"
# Parameter 2: New profiles path -> f.e "D:\USER_PROFILES" (default value is "D:\users")
#
# Execution examples
#
# PS> .\MOVE_PROFILES.ps1 (moves all user profiles to the new location D:\users\<user>"
# PS> .\MOVE_PROFILES.ps1 user1 (moves user1 profile to the new location D:\users\<user>"
# PS> .\MOVE_PROFILES.ps1 user1 G:\folder (moves user1 profile to the new location G:\FOLDER\<user>"
# PS> .\MOVE_PROFILES.ps1 ALL G:\folder (moves all user profiles to the new location G:\FOLDER\<user>"
#
# Execute it as administrator when the user you want to migrate is not logged!!


Param(
  [string] $ACCOUNT = "ALL",
  [string] $NEWPATH = "D:\users"
)

# Obtain all user profiles (excluding system profiles)
$USER_PROFILES = dir -LiteralPath "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" | ? {$_.name -match "S-1-5-21-"} 
 
# Loop to process all profiles
foreach ($USER_PROFILE in $USER_PROFILES) {

    # Obtain registry, profile path, user and profile new path
    $REGISTRY = $($($USER_PROFILE.pspath.tostring().split("::") | Select-Object -Last 1).Replace("HKEY_LOCAL_MACHINE","HKLM:"))
    $OLD_PROFILEPATH = $(Get-ItemProperty -LiteralPath $REGISTRY -name ProfileImagePath).ProfileImagePath.tostring()
    $USER=$OLD_PROFILEPATH.Split("\")[-1]
    $NEW_PROFILEPATH = "$NEWPATH\$USER"
    
    # Process all or the user passed as parameter?
    If ($ACCOUNT -eq "ALL" -or $USER -eq $ACCOUNT)
    {
        Write-Host "User:       $USER"
        Write-Host "Registry:   $REGISTRY"
        Write-Host "Old path:   $OLD_PROFILEPATH"
        Write-Host "New path:   $NEW_PROFILEPATH"
        Write-Host

        # Change the profile path in the registry
        Set-ItemProperty -LiteralPath $REGISTRY -Name ProfileImagePath -Value $NEW_PROFILEPATH
        Write-Host "- Modified Windows registry (ProfileImagePath)"
        Write-Host "- Moving folders to new location ($NEW_PROFILEPATH)..."

        # Move the profile folders to the new location
        $ROBOCOPY_COMMAND = "robocopy /e /MOVE /copyall /r:0 /mt:4 /b /nfl /xj /xjd /xjf $OLD_PROFILEPATH $NEW_PROFILEPATH > robocopy_$USER.log"
        Invoke-Expression $ROBOCOPY_COMMAND
        Write-Host "- Done!"
        Write-Host "-------------------------------"        
    }
} 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .