Solved Batch file copy cmds not working correctly.

SnakeFist

New member
Member
Local time
10:24 AM
Messages
73
I'm trying to learn batch cmds and i figured the best way to learn is to make one.
I started this about 6 months ago and got it to half work. Tried to get it to work and gave up. Saw it while cleaning my drives up and figured i give it another shot.

Heres the problem.
After choosing 1 and letting it complete, it will go back to the menu like i want it to. But when i go to choose 2 it will do 1 again. If i choose 2 it will redo 1 again. Same for if i close it out and choose 2 then let it finish then choose 3 it will do 2 again same if i chose 3 first. When i close out and do roaming or local it will either copy over half the folder or copy over the folder plus the ubisoft folder.

So trying to fix it it now returns Invalid drive specification error. Even when i chose 7 to exit on start up it gives an Invalid drive specification error.

I was trying to have the batch file after getting everything right to copy all the locations to the folder the batch file is in. I was also going to make it where it copied it back to the original locations so it will be a back up and restore.

So can anyone help me and see where i went wrong? I figured if i can get this right then restoring them would just mean a reversal of the codes.

View attachment Game Saves Backup & Restore.bat
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built By Yours Truly.
OS
Windows 7 Ultimate x64 SP1
CPU
AMD FX 8350
Motherboard
Gigabyte 990FXA-UD3
Memory
G-Skill Sniper Series 16 GB
Graphics Card(s)
MSI GTX 970
Monitor(s) Displays
Sony Bravia 40 Inch
Screen Resolution
1920x1080 Full Pixel
Hard Drives
Kingston Hyper X Savage SSD 240GB (OS Drive)
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Western Digital Black 2TB
PSU
Antec 900 Watt High Current Gamer
Case
Cooler Master Trooper Full Tower With View Window
Cooling
Noctua D14 Push Pull Air Cooler
Keyboard
Razer Blackwidow Chroma v2
Mouse
Logitech G700s 13 Button Gaming Mouse
Internet Speed
250 mB/s
Antivirus
None
Browser
Firefox
The problem is right after the command:
Code:
SET /P M=Type 1, 2, 3, 4, 5 or 6 then press ENTER:

That command tells the batch file to get the user's selection (1-6), but then there are no subsequent commands telling the script to branch elsewhere depending on that selection. As a result, regardless of the selection the script always executes the immediately following commands:
Code:
IF %M%==1 set drive=F:\Save Game Files\Goes Back To Steam Userdata
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Steam\userdata" "%drive%"
GOTO Menu
The script never gets below that because the first "GOTO Menu" always short-circuits it.

To show you what's happening, substitute the following code for the entire bottom half of your script:
Code:
SET /P M=Type 1, 2, 3, 4, 5 or 6 then press ENTER:

cls
echo You selected: 

IF %M%==1 echo 1
echo you should only be here if 1 is selected
GOTO Menu
IF %M%==2 echo 2
GOTO Menu
IF %M%==3 echo 3
GOTO Menu
IF %M%==4 echo 4
GOTO Menu
IF %M%==5 echo 5
GOTO Menu
IF %M%==6 echo 6
GOTO Menu
IF %M%==7 EXIT
Pause
This is basically your code except I've stripped out all the "meat" of what each selection is supposed to perform just to focus on the program flow. Run that script and notice the responses as you press each selection.

Now try replacing the bottom half of your script with the following instead:
Code:
SET /P M=Type 1, 2, 3, 4, 5 or 6 then press ENTER:

cls
echo You selected: 

goto %M%

:1
echo 1
GOTO Menu
:2
echo 2
GOTO Menu
:3
echo 3
GOTO Menu
:4
echo 4
GOTO Menu
:5
echo 5
GOTO Menu
:6
echo 6
GOTO Menu
:7
EXIT
Pause
Now your program flow branches via the "goto %M%" to the additional labels identifying each branch. Run this script and notice the difference.

BTW, you can then also eliminate the "IF %M%==" conditions because the program is only going to get to that branch when the condition is met anyway, so the "IF %M%" becomes redundant.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Optiplex 7050
OS
Windows 7/8.1/10 multiboot
CPU
Intel Core i7-7700
Motherboard
Dell, Intel Q270 chipset
Memory
48GB (2x16GB Crucial DDR4-3200 + 2x8GB Hynix DDR4-2400)
Graphics Card(s)
Intel HD630 + AMD Radeon R7 450 PCIe
Monitor(s) Displays
Asus VC279 (27")
Screen Resolution
1920x1080
Hard Drives
Toshiba M.2 NVMe (256GB),
Samsung 960 Evo (500GB),
WD Red Plus 80EFBX (8TB)
look at AutoIt Scripting Language - AutoIt it has lots of built incmds to make life simple and you can have graphics and more and its free with lots of support and you can create an .exe with it
 

My Computer

Computer type
PC/Desktop
OS
win 8 32 bit
Another way is use brackets following the IF statement


IF %M% EQU1 (set drive=F:\Save Game Files\Goes Back To Steam Userdata
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Steam\userdata" "%drive%"
GOTO Menu
)
 

My Computers

System One System Two

  • Computer type
    PC/Desktop
    OS
    7 X64
    CPU
    i5 8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Hard Drives
    various
    PSU
    pure power 11 400w cm
    Case
    Coolermaster
    Cooling
    cryorig m9i
  • Computer type
    PC/Desktop
    OS
    7x64
    CPU
    g5400
    Motherboard
    ga b365m ds3h
    Memory
    8gb ddr4 2400
    PSU
    xfx pro 450w
The problem is right after the command:
Code:
SET /P M=Type 1, 2, 3, 4, 5 or 6 then press ENTER:
That command tells the batch file to get the user's selection (1-6), but then there are no subsequent commands telling the script to branch elsewhere depending on that selection. As a result, regardless of the selection the script always executes the immediately following commands:
Code:
IF %M%==1 set drive=F:\Save Game Files\Goes Back To Steam Userdata
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Steam\userdata" "%drive%"
GOTO Menu
The script never gets below that because the first "GOTO Menu" always short-circuits it.

To show you what's happening, substitute the following code for the entire bottom half of your script:
Code:
SET /P M=Type 1, 2, 3, 4, 5 or 6 then press ENTER:

cls
echo You selected: 

IF %M%==1 echo 1
echo you should only be here if 1 is selected
GOTO Menu
IF %M%==2 echo 2
GOTO Menu
IF %M%==3 echo 3
GOTO Menu
IF %M%==4 echo 4
GOTO Menu
IF %M%==5 echo 5
GOTO Menu
IF %M%==6 echo 6
GOTO Menu
IF %M%==7 EXIT
Pause
This is basically your code except I've stripped out all the "meat" of what each selection is supposed to perform just to focus on the program flow. Run that script and notice the responses as you press each selection.

Now try replacing the bottom half of your script with the following instead:
Code:
SET /P M=Type 1, 2, 3, 4, 5 or 6 then press ENTER:

cls
echo You selected: 

goto %M%

:1
echo 1
GOTO Menu
:2
echo 2
GOTO Menu
:3
echo 3
GOTO Menu
:4
echo 4
GOTO Menu
:5
echo 5
GOTO Menu
:6
echo 6
GOTO Menu
:7
EXIT
Pause
Now your program flow branches via the "goto %M%" to the additional labels identifying each branch. Run this script and notice the difference.

BTW, you can then also eliminate the "IF %M%==" conditions because the program is only going to get to that branch when the condition is met anyway, so the "IF %M%" becomes redundant.

So after 1 in your code do i put set drive=F:\Save Game Files\Goes Back To Steam Userdata
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Steam\userdata" "%drive%"?
Like i said i'm just learning this. But i see i didn't learn much at all from my research except the wrong way to do stuff.

I used this as the basis of my batch file that is why i thought it was good.

Batch Files - Create a Menu to Execute Commands
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built By Yours Truly.
OS
Windows 7 Ultimate x64 SP1
CPU
AMD FX 8350
Motherboard
Gigabyte 990FXA-UD3
Memory
G-Skill Sniper Series 16 GB
Graphics Card(s)
MSI GTX 970
Monitor(s) Displays
Sony Bravia 40 Inch
Screen Resolution
1920x1080 Full Pixel
Hard Drives
Kingston Hyper X Savage SSD 240GB (OS Drive)
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Western Digital Black 2TB
PSU
Antec 900 Watt High Current Gamer
Case
Cooler Master Trooper Full Tower With View Window
Cooling
Noctua D14 Push Pull Air Cooler
Keyboard
Razer Blackwidow Chroma v2
Mouse
Logitech G700s 13 Button Gaming Mouse
Internet Speed
250 mB/s
Antivirus
None
Browser
Firefox
Another way is use brackets following the IF statement


IF %M% EQU1 (set drive=F:\Save Game Files\Goes Back To Steam Userdata
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Steam\userdata" "%drive%"
GOTO Menu
)

If i do that, i only did the first one as a test.

I get this error.

'"C:\Program Files (x86)\Steam\userdata"' is not recognized as an internal or external command,

operable program or batch file.

Here is what i did exact as yours. And got error above.

(set drive=F:\Save Game Files\Goes Back To Steam Userdata
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Steam\userdata" "%drive%"
GOTO Menu
)
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built By Yours Truly.
OS
Windows 7 Ultimate x64 SP1
CPU
AMD FX 8350
Motherboard
Gigabyte 990FXA-UD3
Memory
G-Skill Sniper Series 16 GB
Graphics Card(s)
MSI GTX 970
Monitor(s) Displays
Sony Bravia 40 Inch
Screen Resolution
1920x1080 Full Pixel
Hard Drives
Kingston Hyper X Savage SSD 240GB (OS Drive)
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Western Digital Black 2TB
PSU
Antec 900 Watt High Current Gamer
Case
Cooler Master Trooper Full Tower With View Window
Cooling
Noctua D14 Push Pull Air Cooler
Keyboard
Razer Blackwidow Chroma v2
Mouse
Logitech G700s 13 Button Gaming Mouse
Internet Speed
250 mB/s
Antivirus
None
Browser
Firefox

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built By Yours Truly.
OS
Windows 7 Ultimate x64 SP1
CPU
AMD FX 8350
Motherboard
Gigabyte 990FXA-UD3
Memory
G-Skill Sniper Series 16 GB
Graphics Card(s)
MSI GTX 970
Monitor(s) Displays
Sony Bravia 40 Inch
Screen Resolution
1920x1080 Full Pixel
Hard Drives
Kingston Hyper X Savage SSD 240GB (OS Drive)
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Western Digital Black 2TB
PSU
Antec 900 Watt High Current Gamer
Case
Cooler Master Trooper Full Tower With View Window
Cooling
Noctua D14 Push Pull Air Cooler
Keyboard
Razer Blackwidow Chroma v2
Mouse
Logitech G700s 13 Button Gaming Mouse
Internet Speed
250 mB/s
Antivirus
None
Browser
Firefox
So after 1 in your code do i put set drive=F:\Save Game Files\Goes Back To Steam Userdata
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Steam\userdata" "%drive%"?
Correct. Where you have:
Code:
[B][COLOR="Red"]IF %M%==1[/COLOR][/B] set drive=F:\Save Game Files\Goes Back To Steam Userdata
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Steam\userdata" "%drive%"
GOTO Menu
replace with:
Code:
[B][COLOR="Red"]:1[/COLOR][/B]
set drive=F:\Save Game Files\Goes Back To Steam Userdata
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Steam\userdata" "%drive%"
GOTO Menu
(Disclaimer: I didn't troubleshoot those commands, but I'm assuming you had at least the "1" option working correctly and your only issue was getting the "2" through "6" options working similarly. I trust there really exists a folder called "F:\Save Game Files\Goes Back To Steam Userdata", for instance.)

What this change does is setup a jump destination labeled "1" for the commands you want to execute when "1" is pressed. Note you're only going to get here if %M% is 1, so the "if %M%==1" is redundant here and can be eliminated.

Make similar changes for the "2" through "7" subsections.

You want each of these subsections to execute if and only if the corresponding number is selected from the menu. To accomplish that kind of discrimination, precede the whole lot with a "goto %M%" jump instruction right after the "SET /P M=Type" command, ala:
Code:
SET /P M=Type 1, 2, 3, 4, 5 or 6 then press ENTER:
cls
goto %M%

What the SET command does is set an environment variable M to whatever number is pressed (i.e., it will perform a "set M=1", or "set M=2", or whatever), then the following "goto %M%" tells the script to jump to the corresponding subsection (i.e., it will translate to "goto 1", or "goto 2", or whatever).

The "cls" is optional, but I added it just to clear the display after each selection to make it look a little cleaner.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Optiplex 7050
OS
Windows 7/8.1/10 multiboot
CPU
Intel Core i7-7700
Motherboard
Dell, Intel Q270 chipset
Memory
48GB (2x16GB Crucial DDR4-3200 + 2x8GB Hynix DDR4-2400)
Graphics Card(s)
Intel HD630 + AMD Radeon R7 450 PCIe
Monitor(s) Displays
Asus VC279 (27")
Screen Resolution
1920x1080
Hard Drives
Toshiba M.2 NVMe (256GB),
Samsung 960 Evo (500GB),
WD Red Plus 80EFBX (8TB)
Correct. Where you have:
Code:
[B][COLOR=Red]IF %M%==1[/COLOR][/B] set drive=F:\Save Game Files\Goes Back To Steam Userdata
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Steam\userdata" "%drive%"
GOTO Menu
replace with:
Code:
[B][COLOR=Red]:1[/COLOR][/B]
set drive=F:\Save Game Files\Goes Back To Steam Userdata
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Steam\userdata" "%drive%"
GOTO Menu
(Disclaimer: I didn't troubleshoot those commands, but I'm assuming you had at least the "1" option working correctly and your only issue was getting the "2" through "6" options working similarly. I trust there really exists a folder called "F:\Save Game Files\Goes Back To Steam Userdata", for instance.)

What this change does is setup a jump destination labeled "1" for the commands you want to execute when "1" is pressed. Note you're only going to get here if %M% is 1, so the "if %M%==1" is redundant here and can be eliminated.

Make similar changes for the "2" through "7" subsections.

You want each of these subsections to execute if and only if the corresponding number is selected from the menu. To accomplish that kind of discrimination, precede the whole lot with a "goto %M%" jump instruction right after the "SET /P M=Type" command, ala:
Code:
SET /P M=Type 1, 2, 3, 4, 5 or 6 then press ENTER:
cls
goto %M%
What the SET command does is set an environment variable M to whatever number is pressed (i.e., it will perform a "set M=1", or "set M=2", or whatever), then the following "goto %M%" tells the script to jump to the corresponding subsection (i.e., it will translate to "goto 1", or "goto 2", or whatever).

The "cls" is optional, but I added it just to clear the display after each selection to make it look a little cleaner.

Ok i went ahead and did the changes you said to make.

Code:
SET /P M=Type 1, 2, 3, 4, 5, 6 or 7 then press ENTER:
cls
goto %M%
:1
set drive=F:\Save Game Files\Goes Back To Steam Userdata
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Steam\userdata" "%drive%"
GOTO Menu
:2
set drive=F:\Save Game Files\Goes Back To Documents Folder
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "%userprofile%\documents" "%drive%"
GOTO Menu
:3
set drive=F:\Save Game Files\Goes Back To Saved Games Folder
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "%userprofile%\Saved Games" "%drive%"
GOTO Menu
:4
set drive=F:\Save Game Files\Goes Back To AppData Folder
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "%AppData%\Local" "%drive%"
GOTO Menu
:5
set drive=F:\Save Game Files\Goes Back To AppData Roaming Folder
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "%AppData%\Roaming" "%drive%"
GOTO Menu
:6
set drive=F:\Save Game Files\Goes Back To Ubisoft Save Games Folder
set backupcmd=xcopy /s /r /y /k /v /e /i
%backupcmd% "C:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\savegames" "%drive%"
GOTO Menu
:7
EXIT
Pause
Everything is working except the appdata\local and appdata\roaming options.
When i choose option 4 i will get the error File not found - Local
0 File(s) copied
When i choose option 5 i will get the error File not found - Roaming
0 File(s) copied
Other then them 2 options not working the rest work great.


The folder F:\Save Game Files\Goes Back To Steam Userdata is just for internal testing.

So basically each location that gets backed up goes into it's own folder inside the save game files folder.

I know that not everyone will have an F:\ drive. I used that location for internal testing purposes. What i want to do is after i get everything working is to have the folder save game files created inside the same folder as where the batch file is.
So the batch file and the save game files are in the same folder cause i also want to if possible to also make it to restore the save game files back to the correct folders where they was backed up from.

So after i get everything correct. I want to add options 7 through 12 to restore what was backed up in options 1 through 6. So 13 will become exit. To make it easy for people who don't know much about computers to be able to backup and restore their save game files with one batch file.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built By Yours Truly.
OS
Windows 7 Ultimate x64 SP1
CPU
AMD FX 8350
Motherboard
Gigabyte 990FXA-UD3
Memory
G-Skill Sniper Series 16 GB
Graphics Card(s)
MSI GTX 970
Monitor(s) Displays
Sony Bravia 40 Inch
Screen Resolution
1920x1080 Full Pixel
Hard Drives
Kingston Hyper X Savage SSD 240GB (OS Drive)
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Western Digital Black 2TB
PSU
Antec 900 Watt High Current Gamer
Case
Cooler Master Trooper Full Tower With View Window
Cooling
Noctua D14 Push Pull Air Cooler
Keyboard
Razer Blackwidow Chroma v2
Mouse
Logitech G700s 13 Button Gaming Mouse
Internet Speed
250 mB/s
Antivirus
None
Browser
Firefox
Ok i went ahead and did the changes you said to make.
[...]
Everything is working except the appdata\local and appdata\roaming options.
When i choose option 4 i will get the error File not found - Local
0 File(s) copied
When i choose option 5 i will get the error File not found - Roaming
0 File(s) copied
Other then them 2 options not working the rest work great.
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.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Optiplex 7050
OS
Windows 7/8.1/10 multiboot
CPU
Intel Core i7-7700
Motherboard
Dell, Intel Q270 chipset
Memory
48GB (2x16GB Crucial DDR4-3200 + 2x8GB Hynix DDR4-2400)
Graphics Card(s)
Intel HD630 + AMD Radeon R7 450 PCIe
Monitor(s) Displays
Asus VC279 (27")
Screen Resolution
1920x1080
Hard Drives
Toshiba M.2 NVMe (256GB),
Samsung 960 Evo (500GB),
WD Red Plus 80EFBX (8TB)
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built By Yours Truly.
OS
Windows 7 Ultimate x64 SP1
CPU
AMD FX 8350
Motherboard
Gigabyte 990FXA-UD3
Memory
G-Skill Sniper Series 16 GB
Graphics Card(s)
MSI GTX 970
Monitor(s) Displays
Sony Bravia 40 Inch
Screen Resolution
1920x1080 Full Pixel
Hard Drives
Kingston Hyper X Savage SSD 240GB (OS Drive)
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Western Digital Black 2TB
PSU
Antec 900 Watt High Current Gamer
Case
Cooler Master Trooper Full Tower With View Window
Cooling
Noctua D14 Push Pull Air Cooler
Keyboard
Razer Blackwidow Chroma v2
Mouse
Logitech G700s 13 Button Gaming Mouse
Internet Speed
250 mB/s
Antivirus
None
Browser
Firefox
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Optiplex 7050
OS
Windows 7/8.1/10 multiboot
CPU
Intel Core i7-7700
Motherboard
Dell, Intel Q270 chipset
Memory
48GB (2x16GB Crucial DDR4-3200 + 2x8GB Hynix DDR4-2400)
Graphics Card(s)
Intel HD630 + AMD Radeon R7 450 PCIe
Monitor(s) Displays
Asus VC279 (27")
Screen Resolution
1920x1080
Hard Drives
Toshiba M.2 NVMe (256GB),
Samsung 960 Evo (500GB),
WD Red Plus 80EFBX (8TB)
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built By Yours Truly.
OS
Windows 7 Ultimate x64 SP1
CPU
AMD FX 8350
Motherboard
Gigabyte 990FXA-UD3
Memory
G-Skill Sniper Series 16 GB
Graphics Card(s)
MSI GTX 970
Monitor(s) Displays
Sony Bravia 40 Inch
Screen Resolution
1920x1080 Full Pixel
Hard Drives
Kingston Hyper X Savage SSD 240GB (OS Drive)
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Western Digital Black 2TB
PSU
Antec 900 Watt High Current Gamer
Case
Cooler Master Trooper Full Tower With View Window
Cooling
Noctua D14 Push Pull Air Cooler
Keyboard
Razer Blackwidow Chroma v2
Mouse
Logitech G700s 13 Button Gaming Mouse
Internet Speed
250 mB/s
Antivirus
None
Browser
Firefox
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Optiplex 7050
OS
Windows 7/8.1/10 multiboot
CPU
Intel Core i7-7700
Motherboard
Dell, Intel Q270 chipset
Memory
48GB (2x16GB Crucial DDR4-3200 + 2x8GB Hynix DDR4-2400)
Graphics Card(s)
Intel HD630 + AMD Radeon R7 450 PCIe
Monitor(s) Displays
Asus VC279 (27")
Screen Resolution
1920x1080
Hard Drives
Toshiba M.2 NVMe (256GB),
Samsung 960 Evo (500GB),
WD Red Plus 80EFBX (8TB)
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built By Yours Truly.
OS
Windows 7 Ultimate x64 SP1
CPU
AMD FX 8350
Motherboard
Gigabyte 990FXA-UD3
Memory
G-Skill Sniper Series 16 GB
Graphics Card(s)
MSI GTX 970
Monitor(s) Displays
Sony Bravia 40 Inch
Screen Resolution
1920x1080 Full Pixel
Hard Drives
Kingston Hyper X Savage SSD 240GB (OS Drive)
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Western Digital Black 2TB
PSU
Antec 900 Watt High Current Gamer
Case
Cooler Master Trooper Full Tower With View Window
Cooling
Noctua D14 Push Pull Air Cooler
Keyboard
Razer Blackwidow Chroma v2
Mouse
Logitech G700s 13 Button Gaming Mouse
Internet Speed
250 mB/s
Antivirus
None
Browser
Firefox
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built By Yours Truly.
OS
Windows 7 Ultimate x64 SP1
CPU
AMD FX 8350
Motherboard
Gigabyte 990FXA-UD3
Memory
G-Skill Sniper Series 16 GB
Graphics Card(s)
MSI GTX 970
Monitor(s) Displays
Sony Bravia 40 Inch
Screen Resolution
1920x1080 Full Pixel
Hard Drives
Kingston Hyper X Savage SSD 240GB (OS Drive)
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Western Digital Black 2TB
PSU
Antec 900 Watt High Current Gamer
Case
Cooler Master Trooper Full Tower With View Window
Cooling
Noctua D14 Push Pull Air Cooler
Keyboard
Razer Blackwidow Chroma v2
Mouse
Logitech G700s 13 Button Gaming Mouse
Internet Speed
250 mB/s
Antivirus
None
Browser
Firefox
That's good to hear. Thanks for posting back and letting us know how it turned out.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Optiplex 7050
OS
Windows 7/8.1/10 multiboot
CPU
Intel Core i7-7700
Motherboard
Dell, Intel Q270 chipset
Memory
48GB (2x16GB Crucial DDR4-3200 + 2x8GB Hynix DDR4-2400)
Graphics Card(s)
Intel HD630 + AMD Radeon R7 450 PCIe
Monitor(s) Displays
Asus VC279 (27")
Screen Resolution
1920x1080
Hard Drives
Toshiba M.2 NVMe (256GB),
Samsung 960 Evo (500GB),
WD Red Plus 80EFBX (8TB)

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built By Yours Truly.
OS
Windows 7 Ultimate x64 SP1
CPU
AMD FX 8350
Motherboard
Gigabyte 990FXA-UD3
Memory
G-Skill Sniper Series 16 GB
Graphics Card(s)
MSI GTX 970
Monitor(s) Displays
Sony Bravia 40 Inch
Screen Resolution
1920x1080 Full Pixel
Hard Drives
Kingston Hyper X Savage SSD 240GB (OS Drive)
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Seagate FireCuda 2TB SSHD
Western Digital Black 2TB
PSU
Antec 900 Watt High Current Gamer
Case
Cooler Master Trooper Full Tower With View Window
Cooling
Noctua D14 Push Pull Air Cooler
Keyboard
Razer Blackwidow Chroma v2
Mouse
Logitech G700s 13 Button Gaming Mouse
Internet Speed
250 mB/s
Antivirus
None
Browser
Firefox
Back
Top