Simple BAT file

G

Guest

Hi, i have tried to create a simple bat file that copies a folder from one
directory to another, but it doesn't work. i am using windows xp. the
contents of the file are:

cd c:
cd C:\Documents and Settings\Rafik\My Documents
copy C:\Documents and Settings\Pinto\My Documents\Pinto C:\

can anybody help.
 
Y

Yves Leclerc

DOS command prompt can not correct use the long files names. Try placing
Documents and Settings\Rafik\My Documents in quotes --> C:\"Documents and
Settings\Rafik\My Documents".
 
D

Detlev Dreyer

Pinto1uk said:
Hi, i have tried to create a simple bat file that copies a folder from
one directory to another, but it doesn't work. i am using windows xp.
the contents of the file are:

cd c:

That's wrong. Note that C: is a *drive* and not a directory. Therefore,
the correct syntax should read
C:
However, you don't need that line anyway.
cd C:\Documents and Settings\Rafik\My Documents

Wrong again. The correct syntax should read
CD \Documents and Settings\Rafik\My Documents
However, you don't need that line anyway.
copy C:\Documents and Settings\Pinto\My Documents\Pinto C:\

Provided that you want to copy the folder ...\Pinto and its subfolders
to C:\ use XCOPY. Example:
XCOPY /i /s "C:\Documents and Settings\Pinto\My Documents\Pinto" C:\Pinto
 
D

Detlev Dreyer

Addendum:
XCOPY /i /s "C:\Documents and Settings\Pinto\My Documents\Pinto"
C:\Pinto

Note the posting's line wrap. Should read:
XCOPY /i /s "...\Pinto\My Documents\Pinto" C:\Pinto
 
R

RobertVA

I wouldn't reccomend copying a lot of files into the root directory.
there is a strict limit to the file count that can be stored there.

Setting the directory to the source folder and then using the entire
path in the copy command seems redundant. The file name should be enough.

Is "Pinto" just a file or a folder within "My Documents"? Application
and data files normally use an extension (.txt, .doc, .htm etc)

Your command tries to copy "C:\Documents" to "and". Without quotation
marks the first space deliniates the end of the source file name AND the
beginning of the destination path. If your path combined with your name
contains ANY spaces you have to enclose the entire path and file name in
a set of quotation marks:

copy "C:\Documents and Settings\Pinto\My Documents\Pinto" C:\
 
R

RobertVA

I wouldn't reccomend copying a lot of files into the root directory.
there is a strict limit to the file count that can be stored there.

Setting the directory to the source folder and then using the entire
path in the copy command seems redundant. The file name should be enough.

Is "Pinto" just a file or a folder within "My Documents"? Application
and data files normally use an extension (.txt, .doc, .htm etc)

Your command tries to copy "C:\Documents" to "and". Without quotation
marks the first space deliniates the end of the source file name AND the
beginning of the destination path. If your path combined with your name
contains ANY spaces you have to enclose the entire path and file name in
a set of quotation marks:

copy "C:\Documents and Settings\Pinto\My Documents\Pinto" C:\
 
R

RobertVA

Pinto1uk said:
Hi, i have tried to create a simple bat file that copies a folder from one
directory to another, but it doesn't work. i am using windows xp. the
contents of the file are:

cd c:
cd C:\Documents and Settings\Rafik\My Documents
copy C:\Documents and Settings\Pinto\My Documents\Pinto C:\

can anybody help.

I wouldn't reccomend copying a lot of files into the root directory. There
is a strict limit to the file count that can be stored there. Folders are
included in the count, so don't get carried away putting folders in the root
directory either.

Setting the directory to the source folder and then using the entire path in
the copy command seems redundant. The file name should be enough. Note that
without the backslash a path designation designates the current directory on
that drive. After you change the directory to "C:\Documents and
Settings\Pinto\My Documents" any files copied to "C:" will be placed in that
folder, accomplishing nothing. You would have to use "C:\" to place them in
the root directory. See below about paths that have spaces in them.

Is "Pinto" just a file or a folder within "My Documents"? Application and
data files normally use an extension (.txt, .doc, .htm etc)
Your command tries to copy "C:\Documents" to "and". Without quotation marks
the first space deliniates the end of the source file name AND the beginning
of the destination path. If your path combined with your name contains ANY
spaces you have to enclose the entire path and file name in a set of
quotation marks:

copy "C:\Documents and Settings\Pinto\My Documents\Pinto" C:\

To copy a folder and its contents consider the xcopy command with additional
flags. Xcopy also has the ability to store multiple files in memory, thus
switching betwen paths quicker and completeing faster. This helps A LOT when
copying multiple files from one floppy to anouther! To see a list of flags
for a DOS/Command Prompt command type the command followed by a slash and a
question mark in a Command Prompt window:

xcopy /?
 
R

RobertVA

Mail reader threw an error. Thought message haddn't been posted. Should
be a bit more information below about xcopy and Command Prompt self
documentation features.
 
S

Steve N.

Brian said:
Oh, really? I just created the following BAT file named Test.bat:

cd %UserProfile%\Local Settings\Temporary Internet Files
dir /a

opened a command line window and entered test.bat. Here's the result.
Looks like long file names are handled just fine.

The difference is probably due to the fact that cd is an internal comman
d and copy is an external command.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top