Mark
Mark

Reputation: 178

.bat Programming - How do I search for a shared drive to copy a file from without specifying the Network Drive letter?

I need to copy files on a specific shared drive. However, some people are mapped to the N: Drive while others are mapped to the T:Drive and so on. There is a specific \server\share used to specify the drive mapping.

What I normally do is copy a file from the shared drive (N:Drive) to the Hard Disk (C:Drive) but not everyone has the same mapping. Some people have the \server\share mapped to the T:Drive instead of the N:Drive.

So is there a way to have the .batch file bypass the letter mapping of the shared drive and just allow me to search for the \server\share? I'll list an example of my current code below and you tell me how you would do it by bypassing the letter

@echo off

xcopy /y "N:\1.0 Blank Folder\Resource1.url" "C:\Program Files\Ericom Software"

xcopy /y "N:\1.0 Blank Folder\Resource2.msg" "C:\Program Files\Ericom Software"

xcopy /y "N:\1.0 Blank Folder\Resource3.lnk" "C:\Program Files\Ericom Software"

echo ********** INITIAL SETUP COMPLETE **********

Now how do I do that withouth using "N:\1.0 Balnk Folder/Resource3.lnk"? It should be "\server\share\1.0 Blank Folder\Resource3.lnk" instead but that doesn't work, I've already tried it. Any ideas?

Thanks, Mark

Upvotes: 0

Views: 97

Answers (2)

Mark
Mark

Reputation: 178

I got the answer to my questions. The above is partially correct but did not work because of the quotes. The correct answer is below:

\servername\sharename\"1.0 Blank Folder\Resource1.url" "C:\Program Files\Ericom Software"

Thank you for your help!

Upvotes: 0

user5721973
user5721973

Reputation:

Drive letters are for MSDos compatability, thus are over twenty years since they were needed. Use UNC. \\server\sharename\folder\file.ext.

copy "\\servername\sharename\1.0 Blank Folder\Resource1.url" "C:\Program Files\Ericom Software"

eg

C:\Users\David Candy>copy\\127.0.0.1\C$\windows\win.ini .\win.ini
        1 file(s) copied.

Upvotes: 1

Related Questions