# Create a batch file for MY SCANS to and external hard drive



## Swazza (May 5, 2010)

Hi,

I am wanting to create a backup (.bat file) for "MY SCAN" which is located in "my document" under "documents" in "Libraries" to back up daily to my external hard drive which is F:/. I am using Windows 7. I have no clue how to do this as I know nothing about DOS. HELP????

Thanks Jane


----------



## Squashman (Apr 4, 2003)

Does this have to be done with a batch file?
Plenty of software out there that can do this just fine.
If you want to do this with a batch file then you should look at using the XCOPY or RoboCopy commands.


----------



## Swazza (May 5, 2010)

No it doesnt have to be done with a batch file but really dont want to spend heaps (preferably none) on software. Any suggestions?


----------



## TheOutcaste (Aug 8, 2007)

This will copy everything from the *My Scan* folder in the currently logged on user's *Documents* folder to the external drive into a folder named *My Scan* in a folder named using the currently logged on user's User Name.
You can double click to run, or open a command prompt and run it by name. If you type anything after the file name, it will list what will be copied, but won't copy anything.

For example, save it to *C:\Scripts* as *MyScanBack.cmd*
Open a command prompt, type *C:\Scripts\MyScanBack* to backup, type *C:\Scripts\MyScanBack -list* to list what will be copied.
Or create shortcuts using either command as the file to run.
Copy the text in the following code block into Notepad and save it someplace handy with a *.cmd* extension, like *MyScanBack.cmd*.
Be sure to change the *Save as Type:* box to *All Files* when saving.

```
@Echo Off
If "%~1"=="" (Set _List=) Else Set _List=/L
Set _Sw=/E /R:2 /W:10 %_List%
Robocopy "%userprofie%\Documents\My Scan" "F:\%Username%\My Scan" %_Sw%
```


----------



## Squashman (Apr 4, 2003)

Swazza said:


> No it doesnt have to be done with a batch file but really dont want to spend heaps (preferably none) on software. Any suggestions?


I think if you searched the Internet you would easily find something.


----------



## Swazza (May 5, 2010)

Awesome thanks. I will give it a go today and let you know how I went.

Cheers


----------



## Swazza (May 5, 2010)

The Outcaste: I tried the above code but no sucess it just wont copy.

Squashman: what do I search for I am a beginner at this an dont have any clue.


----------



## TheOutcaste (Aug 8, 2007)

What is the specific error that you get?
Run it from a Command Prompt so you can see the errors. If needed delete the *@Echo Off* line to show each line as it executes.
The above code assumes it located at *C:\Users\<username>\Documents\My Scans*
One thought that comes to mind, since Vista/Win7 has done away with most of the "*My* " Folder structure, is the My Scans folder really named *My Scans*, or is it just *Scans*?
In the Library, right click the folder, click *Open folder location*. In the right pane, double click the folder to open it. Then click in the address bar to switch the "breadcrumb" display to the true path and make sure the folder name and path matches the batch file.


----------



## Swazza (May 5, 2010)

Outcaste: I ran the command prompt and it came up with:

Error 3 <0x00000003> Assessing Source Directory
C:\ Users\User1%userprofile%\documents\myscans
The system cannot find the path

(Sorry for the crap typing)

In library the path is:

User1/My Documnets/ My Scans


----------



## Squashman (Apr 4, 2003)

Swazza said:


> Error 3 <0x00000003> Assessing Source Directory
> C:\ Users\User1%userprofile%\documents\myscans
> The system cannot find the path


That should tell you something. You probably don't have the path set correctly in the batch file.


----------



## Swazza (May 5, 2010)

What does that mean and how do I fix it? Please help me I really dont understand.


----------



## Squashman (Apr 4, 2003)

I would recommend you just use a program like SyncToy.
http://www.microsoft.com/downloads/...36-98e0-4ee9-a7c5-98d0592d8c52&displaylang=en


----------



## Swazza (May 5, 2010)

Squashman: Maybe if If you could just write a code for me that backs up the whole my documents? 
When I click on my documents the path is C:\Users\User1\Documents\

Thanks


----------



## TheOutcaste (Aug 8, 2007)

Swazza said:


> Outcaste: I ran the command prompt and it came up with:
> 
> Error 3 <0x00000003> Assessing Source Directory
> C:\ Users\User1%userprofile%\documents\myscans
> ...


*%userprofile%* should expand to *C:\Users\User1*. Wouldn't expect to see C:\ Users\User1%userprofile%. I did notice a typo in the code though, it shows *%userprofie%* (missing letter *L*) -- it should be *%userprofile%*. Sorry about that 
All it takes is one misplaced space or double quote, or a missing letter to cause it not to work.

For example, is it *My Scans*, with a space between *My* and *Scans*, or is there no space, *myscans*, as you show in the error message?
Try this corrected code. Remove the space from *My Scans* if you need to:

```
@Echo Off
 If "%~1"=="" (Set _List=) Else Set _List=/L
 Set _Sw=/E /R:2 /W:10 %_List%
 Robocopy "%userprofile%\Documents\My Scans" "F:\%Username%\My Scans" %_Sw%
```
You can copy what you see in the Command Prompt, that will save having to type it, and will make sure nothing gets missed.
To copy the contents of the Command Prompt window:
Right click in the Command Prompt Window, click *Select All*. This will highlight everything.
Press *Enter*. This will copy it to the clipboard.
Return to the browser and right click in the Reply window, then click *Paste*.
Or left click in the reply window and press *CTRL+V*.

To backup the entire *Documents* folder, it's pretty much the exact same code:

```
@Echo Off
If "%~1"=="" (Set _List=) Else Set _List=/L
Set _Sw=/E /R:2 /W:10 %_List%
Robocopy "%userprofile%\Documents" "F:\%Username%\Documents" %_Sw%
```
Thought I'd attach a couple of screen shots to illustrate the difference between the breadcrumb path and the real path that the Address Bar shows.
These two screen shots are of the same folder. The first shows the Breadcrumbs view, with the Friendly name:
*Library->Documents->My Documents*
The second shows the real path after clicking in the address bar:
*C:\Users\TheOutcaste\Documents*


----------



## Swazza (May 5, 2010)

YIPEE!!!! Thanks so much it worked!


----------

