Batch file copy cmds not working correctly.

Page 2 of 2 FirstFirst 12

  1. Posts : 73
    Windows 7 Ultimate x64 SP1
    Thread Starter
       #11

    dg1261 said:
    For troubleshooting purposes, temporarily precede the "%backupcmd% ..." lines in the 4 and 5 subsections with "echo %backupcmd% ..." This will tell the script to echo on screen what command it's designed to perform, in lieu of actually trying to perform it.

    This can be system-dependent, but on my system it reveals subsection 4 is trying to execute:
    xcopy /s /r /y /k /v /e /i "C:\Users\Dan\AppData\Roaming\Local" "F:\Save Game Files\Goes Back To AppData Folder"

    while subsection 5 is trying to execute:
    xcopy /s /r /y /k /v /e /i "C:\Users\Dan\AppData\Roaming\Roaming" "F:\Save Game Files\Goes Back To AppData Roaming Folder"

    Obviously, these commands are only going to work if these folders exist:
    "C:\Users\Dan\AppData\Roaming\Local"
    "F:\Save Game Files\Goes Back To AppData Folder"
    "C:\Users\Dan\AppData\Roaming\Roaming"
    "F:\Save Game Files\Goes Back To AppData Roaming Folder"
    The two C: folder locations look particularly suspicious to me. Check your system to see if Roaming\Local and Roaming\Roaming actually exist. They don't on mine ... hence, the error messages.

    Looking at your script, I see those subsections are drawing part of the filespec from %AppData%, so that's where you're probably running into trouble. You need to modify that or use something else.


    Technical aside: your filespec in subsection 4 finishes with "Local", but you're not telling the OS whether that refers to a file or a folder. If there's a folder named "Local" at "C:\Users\Dan\AppData\Roaming" it will correctly guess you want all the files in the "Local" folder, but if there's no such folder there, it will assume you must be referring to a file named "Local" at that location.

    Since my system has neither a file nor a folder called "Local" in "C:\Users\Dan\AppData\Roaming", the OS is assuming your script is referring to a file and hence the "File not found - Local" error message.

    The same goes for subsection 5.
    I'm trying to back up C:\Users\Your user name here\AppData\Local and C:\Users\your username here\AppData\roaming folders. Where it says your user name here will be the persons user name like in your case you have Dan. I'm sure all windows 7, 8 and 10 has this location.

    I thought i had to use %appdata%\local to point to C:\Users\Your user name here\AppData\Local .
    Same with the appdata\roaming folder.

    There is no Roaming\Local or Roaming\Roaming.
      My Computer


  2. Posts : 396
    Windows 7/8.1/10 multiboot
       #12

    You can see all the environment variables by opening a command-prompt window and typing "set".

    I'm not sure, but I think %appdata% may universally be the ..\appdata\roaming folder and %localappdata% may universally be ..\appdata\local. You might try changing your script from %appdata%\Local to %localappdata%, and %appdata%\roaming to just %appdata%.

    If that doesn't work, you could probably change them to %userprofile%\appdata\local and %userprofile%\appdata\roaming.
      My Computer


  3. Posts : 73
    Windows 7 Ultimate x64 SP1
    Thread Starter
       #13

    dg1261 said:
    You can see all the environment variables by opening a command-prompt window and typing "set".

    I'm not sure, but I think %appdata% may universally be the ..\appdata\roaming folder and %localappdata% may universally be ..\appdata\local. You might try changing your script from %appdata%\Local to %localappdata%, and %appdata%\roaming to just %appdata%.

    If that doesn't work, you could probably change them to %userprofile%\appdata\local and %userprofile%\appdata\roaming.
    Ok everything is working great. Thank you.

    Now is there a command that will let me store the backup folder in the same folder as the batch file?
      My Computer


  4. Posts : 396
    Windows 7/8.1/10 multiboot
       #14

    SnakeFist said:
    Now is there a command that will let me store the backup folder in the same folder as the batch file?
    Well, in assorted places your batch file sets an environment variable per "set drive=F:\Saved Game Files\(etc)..." and then uses that env var in the backup command. So what you need to do somehow is dynamically change that "set drive=" command based on where the batch file is being called from.

    You can probably get close to what you want by tinkering with the %cd% env var*, which represents the "current directory". For instance, open a command-prompt window and switch to the F:\ directory, and "echo %cd%" should return "F:\". Switch to the "F:\Saved Game Files" directory, and "echo %cd%" should return "F:\Saved Game Files". So wherever you put your batch file, change its relevant commands to "set drive=%cd%\..." and go from there.

    Just keep in mind that there are a few scenarios where this may not get you want you want. It depends on how you call your batch file.

    For instance, if you have "mybatchfile.bat" in F:\, it should work properly if you open F:\ in an Explorer window and double-click "mybatchfile.bat". (The %cd% embedded in your batch file should expand to "F:\".)

    In contrast, it will fail if you open a command-prompt window to somewhere else (like "C:\users\me\desktop") and type "f:\mybatchfile". In that case, f:\mybatchfile.bat will still run but the embedded %cd% will expand to "C:\users\me\desktop".

    It's not the end of the world, but just understand there are limits to where and how the %cd% variable can be used.


    * You'll find a comprehensive list of environment variables here.
      My Computer


  5. Posts : 73
    Windows 7 Ultimate x64 SP1
    Thread Starter
       #15

    dg1261 said:
    Well, in assorted places your batch file sets an environment variable per "set drive=F:\Saved Game Files\(etc)..." and then uses that env var in the backup command. So what you need to do somehow is dynamically change that "set drive=" command based on where the batch file is being called from.

    You can probably get close to what you want by tinkering with the %cd% env var*, which represents the "current directory". For instance, open a command-prompt window and switch to the F:\ directory, and "echo %cd%" should return "F:\". Switch to the "F:\Saved Game Files" directory, and "echo %cd%" should return "F:\Saved Game Files". So wherever you put your batch file, change its relevant commands to "set drive=%cd%\..." and go from there.

    Just keep in mind that there are a few scenarios where this may not get you want you want. It depends on how you call your batch file.

    For instance, if you have "mybatchfile.bat" in F:\, it should work properly if you open F:\ in an Explorer window and double-click "mybatchfile.bat". (The %cd% embedded in your batch file should expand to "F:\".)

    In contrast, it will fail if you open a command-prompt window to somewhere else (like "C:\users\me\desktop") and type "f:\mybatchfile". In that case, f:\mybatchfile.bat will still run but the embedded %cd% will expand to "C:\users\me\desktop".

    It's not the end of the world, but just understand there are limits to where and how the %cd% variable can be used.


    * You'll find a comprehensive list of environment variables here.
    Thanks. I'll try it out and do some testing and see how it goes.
      My Computer


  6. Posts : 73
    Windows 7 Ultimate x64 SP1
    Thread Starter
       #16

    Hey it works as expected. I even reversed the commands to make it to be able to restore the files back to where they was.
    How i tested it was i backed up my data using the batch file and installed vm virtual machine installed the programs to make the paths where the data will goes. Which is steam and ubisoft the rest is default in windows.
    It restored the data back to where it belongs.
    Deleted my host data and use guest os data in vm and it backed up very nicely.
    Thank you for helping me. I have added to your rep.
      My Computer


  7. Posts : 396
    Windows 7/8.1/10 multiboot
       #17

    That's good to hear. Thanks for posting back and letting us know how it turned out.
      My Computer


  8. Posts : 73
    Windows 7 Ultimate x64 SP1
    Thread Starter
       #18

    dg1261 said:
    That's good to hear. Thanks for posting back and letting us know how it turned out.
    Your Welcome.
      My Computer


 
Page 2 of 2 FirstFirst 12

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 15:00.
Find Us