Copying Files in Microsoft Windows

MS-DOS

Copying a single file from one location to another

copy foo.txt c:\my\location

Once in the directory that contains the files you want to copy, type a command

copy *.* c:\mydir

If you need to copy files, directories, and subdirectories use the xcopy command.

xcopy foo example /e
COPY /Y /A/B [d:][path]filename /A/B [d:][path][filename] /V
Options

   /Y - Replace existing files without any confirmation prompt.
   /-Y - Displays a confirmation prompt before overwriting the existing files.
   /A - Copy ASCII files
   /B - Copy Binary files
   /V - Check if file was properly copied

The Microsoft DOS operating system with or without Windows 3.x did not support long file names. There was a DOS limitation of an eight character file name or directory, and a three character extension. Windows 3.x is not an operating system.

Using DOS copy command may truncate your file names. If trying to copy files longer the 8 characters, DOS will truncate them with normal COPY. Also COPY will not move all files, it will leave Hidden and System files alone. Windows supports long filenames and allows spaces in file names. DOS does not, so when a filename is longer than 8 characters, DOS will truncate the file name to an abbreviated form that is 8 characters long. For example, the folder "Program Files" is displayed in DOS as "Progra~1".

Both FAT and NTFS use the Unicode character set for their names, which contain several forbidden characters that MS-DOS cannot read in any file name. To generate a short MS-DOS-readable file name for a file, Windows 2000 deletes all of these characters from the long file name and removes any spaces. Because an MS-DOS-readable file name can have only one period, Windows 2000 also removes all extra periods from the file name. Next, Windows 2000 truncates the file name, if necessary, to six characters and appends a tilde ( ~ ) and a number. For example, each nonduplicate file name is appended with ~1 . Duplicate file names end with ~2 , then ~3 , and so on. After the file names are truncated, the file name extensions are truncated to three or fewer characters. Finally, when displaying file names at the command line, Windows 2000 translates all characters in the file name and extension to uppercase.

Windows Command Shell

To bring Cmd.exe into conformity with the Microsoft MS-DOS 6.x and Microsoft Windows 95 command shells (Command.com), Microsoft has added support for overwrite warnings. When you are copying or moving files from one location to another, if the files already exist in the destination folder, you receive an "overwrite" warning that prompts for confirmation before overwriting the file.

This behavior is controllable with the /y switch.

Are you sure you want to copy this file without its properties?

Trying to copy files from the system to removable media such as a USB flash drive and Microsoft prompts an annoying and reoccurring error message. The message is vague and misleading. It relates to NTFS ADS (alternate data streams).

The NTFS file system is inappropriate for flash media. FAT32 is not capable of preserving the NTFS permissions of files being copied from the NTFS formatted hard drive to the FAT32 removable media. The permissions largely include file ownership and file permissions. These are not file "properties" but rather file "permissions."

Even when you select YES to the dialog and check the box for application of the selection to all files, it only applies to files of the specific type. For a different file type the dialog will present itself again. This makes a "fire and forget" unattended file copy process impossible.

Microsoft suggests formatting the removable media NTFS, which is ill-advised. Due to the additional read/write activity necessary for NTFS this would not be good for flash media. NTFS is also less portable. The best solution would be to have the ability to copy without the annoying prompts.

Workarounds / Solutions: (1) Using the command prompt and piping Y for yes. (2) Using third party copy software such as TeraCopy. (3) Getting angry and waiving your fist in the air while damning Microsoft.

Example has f as the removable media. Open the command shell cmd.exe with administrator privileges.

xcopy c:\files f:\ /s/h/r/i/k/e/y

or

robocopy c:\files f:\ /e /b /copyall /xo /it

Copy a lot of files while not stopping for errors / ignore errors

The traditional way using xcopy from console

xcopy $SOURCE $DESTINATION /C /E /Q 

The /C flag forces xcopy to ignore any issues with copying; the /E flag orders xcopy to copy folders (even empty ones), and the /Q flag makes it a quiet operation (otherwise, you'll get an entry for each thing copied).

example:

xcopy d:\*.* c:\recovery /C /E /Q

The new way using robocopy on Windows 7

Robocopy stands for "Robust File Copy." Robocopy functionally replaces Xcopy, with more options. It has been available as part of the Windows Resource Kit starting with Windows NT 4.0, and was first introduced as a standard feature in Windows Vista and Windows Server 2008. The command is robocopy.

Robocopy CAN copy all NTFS file attributes.

robocopy c:\ d:\ /MIR /R:0 /W:0
/MIR = Mirror entire directory structure (can use /E instead)
/R:0 = 0 retries for read/write failures
/W:0 = 0 seconds between retries

Recovering files from bad harddrive.

robocopy E:\source-path\folder\ C:\destination-path\folder /MIR /R:0 /W:0


Robocopy GUI

Robocopy is in Resource Kit Tools. Robocopy is command line in console (MS-DOS emulated command shell). For a GUI version use Robocopy GUI developed by Derk Benisch, a systems engineer with the MSN Search group at Microsoft. Robocopy GUI also extends the functionality of the existing Robocopy tool in some very interesting ways. For example, this tool is multithreaded, allowing you to create a Robocopy script, execute it, and begin creating another one while your first script is still running. It also allows you to save your scripts (even if you don't actually execute them) so that you can create a library of common scripts or share them with your colleagues. And most importantly, Robocopy GUI allows you to save your default settings so you don't have to start from scratch every time.

Robocopy GUI in the downloads section of Microsoft TechNET.

source: Utility Spotlight Robocopy GUI


RichCopy replaces Robocopy GUI (not really)

RichCopy offers a number of granular controls that allow you to tailor file copying to your needs

RichCopy is crap. The options interface is TOO BIG to fit on the screen under many wide screen laptop computers at their native resolution. The interface cannot be resized. There is an ugly splash screen with pixelated images of women which for the life of me I cannot determine what they have to do with a file copy program. This developer is a total amateur and his utility needs a lot of work.

Pass this one by.

Related

See also: How to Backup Personal Data in Windows

Last modified on 29 September 2015, at 16:25