Index | Examples | Syntax XCOPY | DISKCOPY



COPY--Notes

Setting the COPYCMD environment variable You can set the COPYCMD environment variable to specify whether you want the COPY, MOVE, and XCOPY commands to prompt you for confirmation before overwriting a file, whether issued from the command prompt or a batch file. To force the COPY, MOVE, and XCOPY commands to prompt you before overwriting in all cases, set the COPYCMD environment variable /-Y. To force these commands to overwrite in all cases without prompting you, set the COPYCMD environment variable to /Y. Typing any of these commands with the /Y or /-Y switch overrides all defaults and the current setting of the COPYCMD environment variable. Copying to and from devices You can substitute a device name for one or more occurrences of source or for destination. Using or omitting the /B switch when copying to a device When destination is a device (for example, COM1 or LPT1), the /B switch causes MS-DOS to copy data to the device in binary mode. In binary mode, all characters (including such special characters as CTRL+C, CTRL+S, CTRL+Z, and carriage return) are copied to the device as data. Whereas, omission of the /B switch causes MS-DOS to copy data to the device in ASCII mode. In ASCII mode, such special characters as those previously listed may cause MS-DOS to take special action during the copying process. Using the default destination file If you do not specify a destination file, MS-DOS creates a copy with the same name, creation date, and creation time as the original file, placing the new copy in the current directory on the current drive. If the source file is on the current drive and in the current directory and you do not specify a different drive or directory for the destination file, the COPY command stops and MS-DOS displays the following error message: File cannot be copied onto itself 0 File(s) copied Using the /V switch If MS-DOS cannot verify a write operation, it displays an error message. Although recording errors rarely occur with the COPY command, the /V switch lets you verify that critical data has been correctly recorded. The /V switch also slows down the COPY command, because MS-DOS must check each sector recorded on the disk. Using the /A and /B switches The effect of an /A or /B switch depends upon its position on the command line. When the /A or /B switch follows the source filename, COPY performs as shown in the following list: /A Treats the file as an ASCII (text) file and copies data that precedes the first end-of-file character. COPY does not copy the first end-of-file character or the remainder of the file. /B Copies the entire file, including any end-of-file character. When the /A or /B switch follows the destination filename, COPY performs as shown in the following list: /A Adds an end-of-file character as the last character of the file. /B Does not add an end-of-file character. Combining files with the COPY command If you specify more than one source, separating entries with a plus sign (+), COPY combines the files, creating a single file. If you use wildcards in source but specify a single filename in destination, COPY combines all files matching the filename in source and creates a single file with the filename specified in destination. In either case, COPY assumes the combined files are ASCII files unless you specify the /B switch. (Do not combine non-ASCII files without specifying the /B switch; doing so can result in truncated files, since most binary files contain CTRL+Z characters which cause COPY to behave as if it has reached the end of the file.) If the name of the destination file is the same as the name of one of the files being copied (except the first file), the original contents of the destination file are lost. When this happens, COPY displays the following message: Content of destination lost before copy Copying files in subdirectories To copy all of a directory's files and subdirectories, you should use the XCOPY command. Copying zero-length files COPY does not copy files that are 0 bytes long; instead, it deletes such files. Use XCOPY to copy these files. Changing the time and date of a file If you want to assign the current time and date to a file without modifying the file, use a command in the following format. The commas indicate the omission of the destination parameter. copy /b source+,, About ASCII values of characters as hex numbers Knowledge and results are the same aspects of the same case. Example: A school teacher told the students that they should open a specific file, solve a mathematical problem and then erase the contents of that file and deliver the disk in drive a. Bill and Tom said that they finished this exact as they were told. but the next morning the teacher said that Tom didn't told the true story when he said that he finished the job. How? All files was delivered back with the same file date and the file which should be used was created by the teacher as "ECHO. >FILE". Six different combinations. A blank file (B) can either be created with "REM> B" (a zero byte file) or by open an editor and save the file without any contents. This second option wouldn't be the same as "ECHO.> B" (a two byte file) but is depending on what editor is used. Either the first or the second method is used, then both the files B1 and B2 would looks as the same file but the aren't. @rem > B1 echo.> B2 echo Hello>H %1 copy /b H+B1 Ca %( 48 65 6C 6C 6F D A Hello.. )% %2 copy /a H+B1 Cb %( 48 65 6C 6C 6F D A 1A Hello... )% %3 copy /b H+B2 Cc %( 48 65 6C 6C 6F D A D A Hello.... )% %4 copy /a H+B2 Cd %( 48 65 6C 6C 6F D A D A 1A Hello..... )% %5 copy /b B2+H Ce %( D A 48 65 6C 6C 6F D A ..Hello.. )% %6 copy /a B2+H Cf %( D A 48 65 6C 6C 6F D A 1A ..Hello... )% :: Now, what about if "echo Text>> file" ? rem Ca/Cb would become >Cab for %%v in ( .Hello .Text ) do echo%%v>>Cab rem Cc/Cd would become >Ccd for %%v in (.Hello . .Text) do echo%%v>>Ccd rem Ce/Cf would become >Cef for %%v in (. .Hello .Text) do echo%%v>>Cef It's good to know where to find this when you are creating complex stuff (when using a similar syntax). Just choose COPY & Copy Notes here: http://users.cybercity.dk/~bse26236/batutil/help/INDEX.HTM#c Benny, PS.: DOS is fun and fun is DOS .LOG | %(as press F5 in Notepad)% @CLS The word .LOG is on the first line of this batch file. @echo off %(Spy when last used.bat)% :: Nest of spies. :: Too see when this batch file was last executed, just add :: the following two lines and the date of the file will be :: modified. The current system date will be used. if exist %0.bat %0.bat copy /b %0+,, > nul :: Continiue your batch file here, after the 2 lines above. :: Benny, BTW. :: Open this file in Notepad, and you'll be very surprised! echo. :-) pause :-)
-Top- | Examples | Syntax XCOPY | DISKCOPY