Computing.Net > Forums > Programming > Coping files from a removable drive

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Coping files from a removable drive

Reply to Message Icon

Name: pball
Date: June 16, 2007 at 09:30:52 Pacific
OS: xp home
CPU/Ram: 2.0 ghz 1gb
Product: home made
Comment:

I am trying to copy every file and folder from a usb drive to my computer. I believe I need to use the xcopy command. So then how do I get the source folder to change with the drive letter since the drive letter may change.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: June 16, 2007 at 11:15:02 Pacific
Reply:

The way to keep the drive letter from changing is to assign the letter.


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: ghostdog
Date: June 16, 2007 at 19:49:26 Pacific
Reply:

assuming you have 1 usbdrive. here's a vbscript. save as somename.vbs and run from command prompt. cscript somename.vbs
[code]
Dim oFSO, oDrive,objFolder,oUsbDrive,oDestination
Const USBDRIVE=1
oDestination = "c:\test"
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
'Get USB drive letter
For Each oDrive In oFSO.Drives
....If oDrive.DriveType = USBDRIVE And oDrive.DriveLetter <> "A" Then
....WScript.Echo "found usb at", oDrive.DriveLetter
....oUsbDrive = oDrive.DriveLetter & ":\"
....End If
Next
Sub CopyFiles(oPath, oDst)
....Set objFolder = oFSO.GetFolder(oPath)
....For Each Files In objFolder.Files
........WScript.Echo "Copying File",Files ........newDst=oDst&"\"&Files.Name
........oFSO.CopyFile Files,newDst,True
........WScript.Echo Err.Description
....Next
'Recursive copy, uncomment if needed
' For Each oDir In objFolder.SubFolders
' CopyFiles oDir.Path, oDst
' Next
End Sub

CopyFiles oUsbDrive,oDestination
[/code]


0

Response Number 3
Name: pball
Date: June 16, 2007 at 20:58:02 Pacific
Reply:

Thanks for the suggestion Mechanix2Go
and I don't really want a vbscript

So how about a different question how can I get a batch file to find it's location drive and folder wise and make that a variable that can be used in another command


0

Response Number 4
Name: Mechanix2Go
Date: June 16, 2007 at 21:50:46 Pacific
Reply:

If you know the fixed drives, let's say c d e f, this might work. It's a little clunky.

::== letter2.bat
@echo off
setLocal EnableDelayedExpansion

for %%a in (g h i j k) do (
dir %%a: > nul
if not errorlevel 1 set letter=%%a:
)
cls
echo it's !letter!
)
::==


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 5
Name: pball
Date: June 16, 2007 at 21:51:06 Pacific
Reply:

Well Never mind I found a way to get a variable set to the current directory

all i wish is usb drives would autorun like cd's and so forth, stupid windows

Thread over I guess


0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: June 16, 2007 at 22:30:00 Pacific
Reply:

"Well Never mind I found a way to get a variable set to the current directory"

LOL There's a built-in var; it's name is: %CD%


=====================================
If at first you don't succeed, you're about average.

M2



0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Coping files from a removable drive

Shell script to copy a file from local drive www.computing.net/answers/programming/shell-script-to-copy-a-file-from-local-drive-/18791.html

script to copy files from a server www.computing.net/answers/programming/script-to-copy-files-from-a-server-/16825.html

Find all the file from a directory www.computing.net/answers/programming/find-all-the-file-from-a-directory/18102.html