WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

File Operations

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Copying files using XCOPY

Keywords:	 Xcopy attribute bit set copy file dos

Question:

I want to be able to copy only those files with the attribute bit set and then reset the attribute bit, and other switches (i.e. XCOPY /M/V/S/Y). Is there a Winbatch command to do this?

Answer:

Our SEARCHER extender has a sample XCOPY in it, but more of the plain vanilla type rather than the one with all the switches.

If you're planning to use the Searcher extender's example for xcopy.wbt in the help file, you might want to search for the following article from the home page of the tech support database:

Article ID:   W12553
The current version of the Searcher (12/97) as posted in our download area has fixed two problems that existed in previous versions of the Searcher extender:
  1. Searcher can can see empty directories.
  2. Searcher can now copy zero-byte files.

There is no built in command to do an Xcopy. Although you could brute force it with FileItemize, FileAttrGet, FileAttrSet, FileCopy, ItemExtract, ItemCount, and a few other functions, it would be quite an ordeal.

Mostly just use the DOS xcopy ala...

	RUNWAIT("XCOPY.EXE","C:\DATA\*.* /M/V/S/Y C:\BKUP\DATA\") 
Or...
	RunWait("command.com","/c xcopy   ... ... /M/V/S/Y ...")
To hide it, you might try RunHideWait with the PIF file for command.com that makes it run as a Windowed App and Closes Window on Exit. If you poke around a bit, you'll find the command.pif file.

Question:

Can you offer a code snippet describing how to, for example, copy all files (hidden, system, or otherwise) with attributes and long filenames intact from C:\Windows to D:\Windows? Preferably, with one line as can be done using XCopy32.

Answer:

TARGET="some directory info"
MONTH="other directory info"
BoxOpen("Copying files","")
BoxText("Copying Netscape bookmark file... ")
RunWait("XCOPY32.exe"," /c /e /h /q /k \\talon\talon_c\Data\Apps\Netscape\%TARGET%%MONTH%\Data\Apps\Netscape\ ")
 
BoxText("ECHO Copying Quicken data files... ")
RunWait("XCOPY32.EXE"," /c /e /h /q /k \\blazer\blazer_c\Data\Apps\Quicken\ %TARGET%%MONTH%\Data\Apps\Quicken\ ")

BoxText("Copying Eudora mail files... ")
RunWait("XCOPY32.EXE"," /c /e /h /q /k \\blazer\blazer_c\Data\Mail\ %TARGET%%MONTH%\Data\Mail\")
Again, if you're having a problem with a window not closing properly, you will need a pif/shortcut to make it close. Your PIF file should be set to a windowed- (rather than full screen) window, and the "Close Window on Exit" should be checked.

In Windows 95, a PIF file is automatically created for your DOS application if you make any changes to how it's run, like if you change the DOS app to be a windowed app, rather than full screen. The PIF file will be stored in the C:\WINDOWS\PIF directory. The PIF directory is a hidden directory.

After you get the XCOPY stuff running 110% perfectly - with the DOS boxes closing (controlled by PIF files or shortcuts), THEN you change the RunWait to RunHideWait to hide the DOS boxes.

TIP: There are various tricks where with a single BAT file and a single PIF file for the BAT file you can do anything.
The BAT file should look like:

        %1 %2 %3 %4 %5 %6 %7 %8 %9
        PAUSE      ;Note: pause for debugging only
Make a pif/shortcut for it. Then call it with something like:
        Runwait("mybat.bat","xcopy ....") 
Then you don't have to manage a whole bunch of PIF files.
Article ID:   W13229
Filename:   Copying files XCOPY.txt
File Created: 1999:06:30:11:31:28
Last Updated: 1999:06:30:11:31:28