Unable to restore file due to long file name

I was working with a customer who had accidently deleted some files when copying them to a different drive. When trying to restore them using the Previous Versions option, I got a message saying that the source file name was too long. I tried everything, but eventually the steps below worked for me:
  1. Right click on the folder you're trying to restore from shadow copy and chose Previous Versions. Chose a date and click on Open.
  2. Right click on any file or folder within the previous folder and chose Properties. On the General tab copy what's shown in 'location', e.g.: \\localhost\D$\@GMT-2011.09.20-06.00.04\_Data
  3. Open cmd.exe and type in - subst X: \\localhost\D$\@GMT-2011.09.20-06.00.04\_Data
  1. Open PowerShell and use robocopy to copy content of X:  - robocopy Z: D:\Folder\ /E /COPYALL
  1. Check that all files have been copied.
  2. When finished type - subst X: /D in cmd.exe

Networking restore Windows