Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Batch File Copy Command


  • Please log in to reply
2 replies to this topic

#1 AMBER LEAF999

AMBER LEAF999

  • Members
  • 44 posts
  • OFFLINE
  •  
  • Location:chester/cheshire/uk
  • Local time:09:20 PM

Posted 12 July 2008 - 10:17 AM

hello every one
i am just started to learn about batch files, and done some really basic ones
So i was just trying out the copy command just to try one for myself, but seem to be getting stuck

"EXAMPLE" I WAS TRYING TO COPY C:\TEMP TO C:\Documents and Settings\ROWLEY.PRIVATE-3264A01\My Documents
I also tryed copy c:\temp to c:\my documents.

but as i am new to this i am doing something wrong can anyone shed any light on this for me. i am using windows xp.




Copies one or more files to another location.
COPY [/A | /B] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination] [/A | /B]] [/V] [/Y | /-Y]

source Specifies the file or files to be copied.
/A Indicates an ASCII text file.
/B Indicates a binary file.
destination Specifies the directory and/or filename for the new file(s).
/V Verifies that new files are written correctly.
/Y Suppresses prompting to confirm you want to overwrite an existing destination file.
/-Y Causes prompting to confirm you want to overwrite an existing destination file.

The switch /Y may be preset in the COPYCMD environment variable. This may be overridden with /-Y on the command line.

To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format).

Examples

copy *.* a:

Copy all files in the current directory to the floppy disk drive.

copy autoexec.bat c:\windows

Copy the autoexec.bat, usually found at root, and copy it into the windows directory; the autoexec.bat can be substituted for any file(s).

copy win.ini c:\windows /y

Copy the win.ini file in the current directory to the windows directory. Because this file already exists in the windows directory it normally would prompt if you wish to overwrite the file. However, with the /y switch you will not receive any prompt.

copy myfile1.txt+myfile2.txt

Copy the contents in myfile2.txt and combines it with the contents in myfile1.txt.
TOSHIBA LAPTOP L300-1BV/ WINDOWS VISTA HOME PREMIUM SP2 / 2 GB RAM/ 32 BIT /windows 7 vista home premium, 3GB Ram/ 64 bit

BC AdBot (Login to Remove)

 


m

#2 usasma

usasma

    Still visually handicapped (avatar is memory developed by my Dad


  • BSOD Kernel Dump Expert
  • 25,071 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Southeastern CT, USA
  • Local time:03:20 PM

Posted 12 July 2008 - 02:34 PM

The copy command works on files, not on directories. So, for example, if you wanted to copy all the files in the Temp directory (NOT A GOOD IDEA, BTW - it'll copy a whole bunch of nonsense stuff) to your My Documents folder the syntax would be:

COPY C:\TEMP\*.* TO C:\Documents and Settings\ROWLEY.PRIVATE-3264A01\My Documents\*.*

This will copy everything in the C:\Temp directory to the My Documents directory that's indicated here. The use of the wildcards of *.* means that it will copy everything with entries before the . and everything after the .

It'd be a better experiment (IMO) to just copy 1 text file from the Temp directory to the My Documents directory. In this case it'd be:

COPY C:\TEMP\filename.txt TO C:\Documents and Settings\ROWLEY.PRIVATE-3264A01\My Documents\*.*

You'll end up with a document named filename.txt (if it exists in your Temp directory) in your My Documents folder.

Just for experimentation, try typing "dir *." (without the quotes) at the command prompt. It'll give you a listing of the directories that are located within the folder that your command prompt is open to.

- John  (my website: http://www.carrona.org/ )
**If you need a more detailed explanation, please ask for it. I have the Knack. **  If I haven't replied in 48 hours, please send me a message.

 

My eye problems have recently increased and I'm having difficult reading posts. (23 Nov 2017)
FYI - I am completely blind in the right eye and ~30% blind in the left eye.

If the eye problems get worse suddenly, I may not be able to respond.
If that's the case and help is needed, please PM a staff member for assistance.


#3 AMBER LEAF999

AMBER LEAF999
  • Topic Starter

  • Members
  • 44 posts
  • OFFLINE
  •  
  • Location:chester/cheshire/uk
  • Local time:09:20 PM

Posted 12 July 2008 - 04:05 PM

hello usasma
Yes i did try that but nothing, tryed it in a batch file and at the command prompt at the command prompt it kept saying "system unable to find file"

After messing around i did manage to do it at the command prompt i went to the directory that i was copying the file to
which was C:\Documents and Settings\ROWLEY.PRIVATE-3264A01\My Documents then used the xcopy command

"EXAMPLE"
DIRECTORY C:\Documents and Settings\ROWLEY.PRIVATE-3264A01\My Documents XCOPY C:\TEMP\TEST.FILE /E

THAT WORKED FINE SO HOW WOULD THIS BE PUT IN A BATCH FILE.

DON'T REALLY WANT TO MESS AROUND TO MUCH BUT IF I PUT THAT IN A BATCH FILE WOULD IT WORK ...THANKS :thumbsup:
TOSHIBA LAPTOP L300-1BV/ WINDOWS VISTA HOME PREMIUM SP2 / 2 GB RAM/ 32 BIT /windows 7 vista home premium, 3GB Ram/ 64 bit




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users