Batch file to copy entire directory




















I'm writing a batch script that does a copy. I want to script it to copy an entire folder. When I want to copy a single file, I do this. If I have a folder with this structure, is there a command to copy this entire folder with its contents all at once while preserving the exact structure. Robocopy replaces Xcopy. It comes with Windows 8, 8.

I suspect that the xcopy command is the magic bullet you're looking for. It can copy files, directories, and even entire drives while preserving the original directory hierarchy. There are also a handful of additional options available, compared to the basic copy command. Check out the documentation here. If your batch file only needs to run on Windows Vista or later, you can use robocopy instead, which is an even more powerful tool than xcopy , and is now built into the operating system.

It's documentation is available here. For the experiments, I wrote some code in the scripting language Open Object Rexx and the editor macro language Kexx with the text editor KEdit.

The experiments all had to do with using XCOPY to copy one directory with several files and subdirectories. The experiments consisted of 10 cases. All 10 cases were attempting to do the same copying operation. Of the three cases that did copying, they all did the same copying, that is, gave the same results. So in this way can get a copy of directory X. This change in time-date stamps can be awkward for a copy of a directory with a lot of downloaded Web pages: The HTML file of the Web page will have its original time-date stamp, but the corresponding subdirectory for files used by the HTML file will have the time-date stamp of the run of XCOPY.

In the code, type the actual values instead of the capital text. Save the batch file. Save the newly edited batch file and place it anywhere you want. Execute the file. Your specified file will be copied from its current location to the one you have specified in the destination address. Include your email address to get a message when this question is answered.

Helpful 0 Not Helpful 0. The file addresses must be properly enclosed in the quotations as specified in the code. The base file will remain on its original location, and will also be copied to its new location as specified in the batch file. Submit a Tip All tip submissions are carefully reviewed before being published. Don't usually use to copy folders with large data inside them. You Might Also Like How to.

How to. Co-authors: 2. Updated: May 18, Connect and share knowledge within a single location that is structured and easy to search. I try to copy the folder FolderA contains html and php sites which is in the same directory as the.

It is just a file with no extension and the file has html code from some of my files as content!? Here you go. This will check for the folder and if it does not exist, creates it then moves the files to the newly created folder.

Pretty much what aschipfl had but in a complete script for you with checks. Alright, lets go nice and simple then. This is the only line you need to accomplish what you want to do. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Copy whole folder with. Asked 5 years, 6 months ago.



0コメント

  • 1000 / 1000