English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories
3

In a batch file, I'm trying to copy all files from a particular folder on a shared drive to a specific folder on everyones computer. The following was an attempt:

Copy S:\Example\Folders\*.* C:\Program Files\Folder Name\ /-y

If the source is from anywhere on the C: then the code works with spaces in the folder name, but when I'm taking things from the S: then it wold works if the destination contains NO spaces in the folder names:

S:\Example\Folders\*.* C:\ProgramFiles\FolderName\ /-y

What do I need to do to make it copy to folders with spaces in the name?

2007-04-05 13:14:32 · 2 answers · asked by Anonymous in Computers & Internet Software

How many spaces are in that versions before the tild?

2007-04-05 13:23:11 · update #1

THANKS that worked

2007-04-05 13:36:03 · update #2

2 answers

This is an easy fix -- to have DOS intrepret spaces correctly, just enclose each of your paths in quotes,

Copy "S:\Example\Folders\*.*" "C:\Program Files\Folder Name\" /-y

=======================
Some other notes,
1) You may want to use 'xcopy'. It's a bit faster and has some more powerful options.

If you do use 'xcopy' then,

2) If the /destination/ directory doesn't yet exist, then add the "/i" switch. This tells xcopy to assume that the destination is a directory if you're copying more than one file, and it will create the destination dir for you.

3) Add the "/h" switch, if you want to get hidden and system files, too.

4) Add the "/c" switch. This will make the xcopy command continue to additional files/dirs even if it hits an error. This way, you'll get most stuff, then be able to figure out why it's not getting the rest.

5) Add the "/e" switch to copy all sub-directories, too, including empty ones. If you don't need to get empties, then just a "/s" will do.

6) If you want to get all the stuff under \source\, and you're using the "/e" or "/s" switch, then *.* is not required.

7) If you're going to do this more than once, and you want to make sure to overwrite read-only files in your destination, then add the "/r" switch.

8) If you don't want to see the "overwrite <>? (Yes,No, All)" prompt every time you run your batch, then change your "/-y" to a "/y"
===============

So, to copy the files
- including any directories or filenames with spaces in the names,
- and to create the initial destination directory,
- and get any hidden and system files,
- and to continue on errors,
- and get sub-directories including empty ones,
- and to overwrite read-only files,
- and to not have an overwrite prompt for existing files,
... your commandline could look like,

xcopy "s:\examples\folders" "c:\program files\folder name" /i /h /c /e /r /-y
(that's all on one line .. Answers wraps the text.)

2007-04-06 00:44:42 · answer #1 · answered by Kevin 7 · 3 0

Easiest way is probably to use the 8.3 format file folder name, ie in the case of program files it would be c:\progra~\ if memory serves

2007-04-05 20:21:22 · answer #2 · answered by y2bmj 4 · 0 0

fedest.com, questions and answers