4

What am I trying to do?

I am changing 'Location' of the AppData/Roaming folder to another partition of the same disk, as shown on the screenshot below.

Changing folder location

The screenshot shows in blue background the destination address for the destination folder. The window is "Roaming Properties" and the selected tab is "Location".

AppData takes up too much space and my "Windows 10" partition is almost out of space, as shown on the screenshot below.

Devices and units

The screenshot shows "Devices and units".

What is happening instead?

I am instead getting the error shown on the screenshot below.

The folder cannot be moved to here

It has the title: 'The folder can't be moved here', and continues by saying:

'Failed to copy files from X to Y . This can happen when one or more files in the origin or destiny folders have a filename longer than 256 characters. The operation was cancelled by the user.'

What have I already tried to do?

  1. Could not find an answer on SuperUser;
  2. I tried to change LongPathsEnabled to 1, but it was already 1;
  3. What I noticed, doing my own experiments, is that the AppData/Roaming/Microsoft subfolder cannot be renamed, deleted or moved, and that it may be the cause of the error. I cannot do anything with it even when using an elevated cmd. So it may be blocking the setting of the new address for the AppData/Roaming folder.

Question:

How to solve the 256 characters error, in order to adequately move the AppData/Roaming folder?

2 Answers2

4

Generally, it is not a good idea to change Windows System folder locations, though it can be done. If some particular application is making AppData too large, try relocating just that app.

Use a tool such as WinDirStat or alternative to analyze the folder and subfolders and find the culprits consuming drive space, and move that app's data.

As an example, the Thunderbird email client profile in AppData/Roaming may be hundreds of megabytes, or even some gigabytes. It can easily be moved elsewhere using its Profile Manager.

2

So warnings aside (yes this is a bad idea, in particular for %appdata%, since it's virtually mapped) there are a couple approaches to deal with the 256-character path limitation.

The first and most applicable to you, is to perform a recursive copy with robocopy. Robocopy is a sophisticated application designed to provide "Robust Copy" functionality, similar to the kinds of features you'd see in Linux's rsync. it will take a bit of work to find the exact set of options you need, but robocopy does not by default limit file operations to objects with a path of less than 256 characters (unless you use the /256 switch).

Another more old-school approach that you can use with almost any copy application is to use the subst command to shorten the path. for instance the command subst b: c:\users\UserName\AppData\Roaming will map the roaming dir to the drive label b:, so when you copy from b:, the path is ~30 characters shorter.

Run5k
  • 16,463
  • 24
  • 53
  • 67
Frank Thomas
  • 37,476