# Solved: XCopy folders & files from desktop to USB drive



## jmbau (Nov 18, 2008)

I'm having great trouble writing a batch file to help my elderly father.

Currently it is like this:



> echo copying books from desktop to Daisy card
> del /S /Q "L:\$VRDTB\*.*"
> RD /s /q "L:\$VRDTB"
> MD "L:\$VRDTB"
> xcopy "C:\Documents and settings\Users\Bill\Desktop\Vision Australia Downloads\*" L:\$VRDTB /s /i /w /c


It removes the $VRDTB folder OK, and then creates a new one (this seemed to be the simplest way of getting an empty folder with the right name).
But it just doesn't copy anything from the folder on the desktop to L drive.

I am running Windows 7. He is running Windows XP.

I'm still trying to get it working: have used XCopy before, but this time I have tried multiple combinations, tested and researched and searched but I simply cannot get it right.

Can anyone tell me where I'm going wrong?

Background: He downloads talking book files and needs to be able to move them onto a card in a USB drive, so as to be able to listen to them with his Daisy device. (As he's vision challenged, doing it himself is quite difficult). The source path, the directory names and the locations are set and I cannot change them.

Source is a folder on his desktop named 'Vision Australia Downloads'. New books are downloaded into this folder as individual folders with a variable name (say, Janice Joplin) containing a bunch of files for the book. The number of these and titles vary.

Destination is L:\$VRDTB (USB slot, and yes the folder has a $ sign as the first character). When he inserts the card into L:, there will be subdirectories under $VRDTB - previous books that need to be removed. Again, number and titles vary.


----------



## foxidrive (Oct 20, 2012)

This should work, but is untested.
The RD /s/q will remove all files and folders.
Xcopy will create the folder by itself.

USB drives can change drive letter so this will detect the existing USB drive by having "\$VRDTB" in the root of the drive. Perhaps that is why your effort failed - the pause at the end will let you see any error messages in case it fails.

If it doesn't copy the files then double check the source path.


```
@echo off
set "USBDRV="
for %%a in (d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist "%%a:\$VRDTB\" set USBDRV=%%a
)
if not defined USBDRV echo THE USB DRIVE WASN'T FOUND & pause&goto :EOF
echo copying books from desktop to Daisy card
RD /s /q "%USBDRV%:\$VRDTB"
xcopy "C:\Documents and settings\Users\Bill\Desktop\Vision Australia Downloads\*" "%USBDRV%:\$VRDTB\" /s /c 
pause
```


----------



## jmbau (Nov 18, 2008)

Thanks for the offer, but that didn't work. This made it treat the USB card/drive as a CD, so something threw up an error message saying there wasn't a disk in the device (whether or not the USB stick was or not). And I continued wiped out ALL files from the USB stick (which I don't want - other folders there have to stay) but didn't copy across any of the new ones. Not quite what I wanted.

But it did point me in the direction of the source path. You're right, it was wrong. I've now got it working on my set up with this code:



> echo copying books from desktop to Daisy card
> del /S /Q "L:\$VRDTB\*.*"
> RD /s /q "L:\$VRDTB"
> MD "L:\$VRDTB"
> xcopy "C:\Users\jane\Desktop\Vision Australia Downloads" L:\$VRDTB /s /i /w /c


I'll try it on his when I'm next there.

I like the idea of having the USB drive detected but can't get it working from this. But appreciate the help.


----------



## foxidrive (Oct 20, 2012)

jmbau said:


> Thanks for the offer, but that didn't work. This made it treat the USB card/drive as a CD, so something threw up an error message saying there wasn't a disk in the device (whether or not the USB stick was or not). And I continued wiped out ALL files from the USB stick (which I don't want - other folders there have to stay) but didn't copy across any of the new ones. Not quite what I wanted.


I tested it and it works fine - except your source path was wrong and it would have wiped the "\$VRDTB" folder the first time and then would not find it the second time after you fixed the path.

You would have had to recreate the "\$VRDTB" folder on the USB stick to run it again.

It cannot wipe out all the files from the USB stick, it can only wipe a "\$VRDTB" folder. And the reason it didn't run a second time is that its also programmed to abort and print an error message if it doesn't find that folder.


----------



## jmbau (Nov 18, 2008)

Foxidrive, I don't want to seem ungrateful, but as I was trying it out (again, following your post) I still get a different result from the one you describe, even when the source path IS correct and the $VRDTB folder does exist. (Yes, of course I understand it needs to be there)

But the code supplied doesn't run; CMD.exe gives this error message: 

'There is no disk in the drive. Please insert a disk into drive \Device\Harddisk3\DR3'

Whether I choose 'Try Again', 'Continue' or 'Cancel' the result is the same: nothing further happens.

Not trying to be difficult here, I was just experimenting to see if I could incorporate recognition of the USB drive. But perhaps it's my set up being different from yours.


----------



## foxidrive (Oct 20, 2012)

It must be some piece of your hardware acting unusually.

Try this batch file - it will echo the drive letter before each test. The drive letter that causes the message will be the last one on the screen before the message. Remove that letter from the string to stop it testing that drive.


```
@echo off
set "USBDRV="
for %%a in (d e f g h i j k l m n o p q r s t u v w x y z) do (
echo testing %%a:
if exist "%%a:\$VRDTB\" echo set USBDRV=%%a
)
pause
```


----------

