Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

DOS/Other DOS/Other
Search Search
Search for:
Tech Support Guy > > >

Solved: XCopy folders & files from desktop to USB drive


(!)

jmbau's Avatar
jmbau jmbau is offline
Computer Specs
Member with 37 posts.
THREAD STARTER
 
Join Date: Nov 2008
Location: Australia
Experience: I
14-Feb-2013, 09:56 PM #1
Question Solved: XCopy folders & files from desktop to USB drive
I'm having great trouble writing a batch file to help my elderly father.

Currently it is like this:

Quote:
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's Avatar
foxidrive foxidrive is online now
Member with 648 posts.
 
Join Date: Oct 2012
Experience: Advanced
15-Feb-2013, 12:42 AM #2
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.

Code:
@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's Avatar
jmbau jmbau is offline
Computer Specs
Member with 37 posts.
THREAD STARTER
 
Join Date: Nov 2008
Location: Australia
Experience: I
15-Feb-2013, 03:24 AM #3
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:

Quote:
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's Avatar
foxidrive foxidrive is online now
Member with 648 posts.
 
Join Date: Oct 2012
Experience: Advanced
15-Feb-2013, 05:50 AM #4
Quote:
Originally Posted by jmbau View Post
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's Avatar
jmbau jmbau is offline
Computer Specs
Member with 37 posts.
THREAD STARTER
 
Join Date: Nov 2008
Location: Australia
Experience: I
17-Feb-2013, 08:32 PM #5
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's Avatar
foxidrive foxidrive is online now
Member with 648 posts.
 
Join Date: Oct 2012
Experience: Advanced
17-Feb-2013, 08:42 PM #6
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.

Code:
@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
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑