title: Robocopy script to transfer user data from old PC to new PC
body: <p>I am trying to write a script that I can use to remotely transfer data from an end user's computer, to a new one I am preparing for them.  I will need to transfer data from multiple user profiles, so I have written it to cycle through the user profiles on the old machine, but I am unsure of the correct syntax in a couple places, specifically what variable I need to reference the current user folder as the script cycles through them (see the question marks in the directories listed below).</p>
  
  <p>I wrote it to only copy user profiles that have been used in the last 90 days.  I would like to copy a few profiles such as Public, Default, etc regardless of age, but I will probably just add a few more Robocopy lines to accomplish that.</p>
  
  <p>Can anyone advise me on what the syntax needs to be where the question marks appear below?  This would be $_ in Powershell, but I'm not sure what it is in a CMD batch file.</p>
  
  <p>Thanks in advance, </p>
  
  <p>Andrew</p>
  
  <pre><code>@echo off
  
  Set /p OldPC=Please enter the old PC name:
  Set /p NewPC=Please enter the new PC name:
  
  for /D %%D in ("\\%OldPC%\USERS\*") do (robocopy "\\%OldPC%\USERS\?\Desktop" "\\%NewPC%\Users\?\Desktop" /E /Z /W:10 /COPYALL /MAXAGE:90
  for /D %%D in ("\\%OldPC%\USERS\*") do (robocopy "\\%OldPC%\USERS\?\Documents" "\\%NewPC%\Users\?\Documents" /E /Z /W:10 /COPYALL /MAXAGE:90
  for /D %%D in ("\\%OldPC%\USERS\*") do (robocopy "\\%OldPC%\USERS\?\Favorites" "\\%NewPC%\Users\?\Favorites" /E /Z /W:10 /COPYALL /MAXAGE:90
  for /D %%D in ("\\%OldPC%\USERS\*") do (robocopy "\\%OldPC%\USERS\?\Pictures" "\\%NewPC%\Users\?\Pictures" /E /Z /W:10 /COPYALL /MAXAGE:90
  </code></pre>