Trying to Backup Libraries on Windows 7 Using the Following Batch File

-2
@echo off
echo  %DATE%,%TIME%,%USERNAME%,%COMPUTERNAME% >>  \\ds.fordham.edu\Users\migrate.log
mkdir  P:\Saved-%computername%\
net use > P:\Saved-%computername%\SPARES.txt
robocopy "%LIBRARIES%\Music" P:\Saved-%computername%\Music /E  /LOG:P:\Saved-%computername%\copylog.log  /np 
robocopy "%USERPROFILE%\Desktop"     P:\Saved-%computername%\Desktop /E /LOG+:P:\Saved-%computername%\copylog.log /np 
robocopy "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook" P:\Saved-%computername%\Outlook *.pst /E /LOG+:P:\Saved-%computername%\copylog.log /np 
robocopy "%USERPROFILE%\" "P:\Saved-%computername%\PKCU  /E /LOG+:P:\Saved-%computername%\copylog.log /np 
robocopy "%LIBRARIES%\Pictures" "P:\Saved-%computername%\Pictures" /E /LOG+:P:\Saved-%computername%\copylog.log /np 
robocopy "%LIBRARIES%\Documents" "P:\Saved-%computername%\Documents" /E /LOG+:P:\Saved-%computername%\copylog.log /np 
pause

I keep getting

ERROR 2 (0x00000002) Accessing Source Directory
The system cannot find the file specified.

For each directory/library. Is there something wrong with my script? Any information would be most appreciated. Thanks

command-line
asked on Super User Apr 11, 2013 by k3i • edited Apr 11, 2013 by Simon

1 Answer

1

There is no %LIBRARIES% variable. Use %USERPROFILE% instead, which will point you to c:\Users\<username>. You can safely use english names (like Music) regardless of the locale.


Each "Library" is in fact a virtual folder that displays content gathered from (possibly) many different folders. By default, each user library has two folders attached:

  • %USERPROFILE%\<library_type>
  • %PUBLIC%\<library_type>

User may add any number of additional folders via library properties panel.

Take a note, that the solution I provided (using %USERPROFILE%) will not reach any additional folders you may have added to your libraries. On a default setup, though, it will work well.

answered on Super User Apr 11, 2013 by Michał Sacharewicz • edited Apr 11, 2013 by Michał Sacharewicz

User contributions licensed under CC BY-SA 3.0