Windows Copy File Cmd

If you’re doing work at the command line on your Windows box, it’s sometimes useful to copy the output of a command to the clipboard, but who wants to try and scroll and click to use copy and paste? Here’s how to do it the easy way.

Note: For the purposes of our exercise, we’ll be using the built-in clip utility in Windows 7 or Vista—if you are using Windows XP, you can download clip.exe from Microsoft, just make sure to save the file in the Windows directory.

Windows Cmd Copy File From Network Share

Windows Copy File Cmd

Copy Output from Command Line Applications to the Clipboard

To copy text from a command to the clipboard, we’ll just pipe it into the clip command, like this:

I am trying to make a batch file to copy a shortcut.lnk from a network folder and have it placed on the desktop's of certain users. Is this the correct command in the.bat? Copying files using PowerShell. Start by opening Windows PowerShell in Windows 8.1. All the commands in this article are run in the context of the logged-in user. Press the WINDOWS key to switch to the Start screen. Type powershell and make sure that Windows PowerShell is selected in the search results on the left of the Start screen.

<command> | clip

For example, if you wanted to output from the echo command into the clipboard, you could do this:

You can also use redirection to send a text file directly into the clip utility, like this:

clip < filename.txt

In this example I’m gonna put the contents of the single.php file onto the clipboard:

Of course, you could also use the type command and then pipe it to the clipboard like so:

Regardless of the one you use, you’ll then be able to paste the content into any other application that you’d like:

Create a Context Menu Helper to Copy File Contents to the Clipboard

You can take the clip utility a step further by adding a context menu item that lets you copy the contents of any file directly to the clipboard. All you’ll need to do is follow the instructions in the following article, or download the reghack file.

And of course, don’t forget that you can always copy the path of the file to the clipboard through the context menu.

READ NEXTFile
  • › Does Your Computer Have a Virus? Here’s How to Check
  • › Wi-Fi vs. ZigBee and Z-Wave: Which Is Better?
  • › What Does “FWIW” Mean, and How Do You Use It?
  • › How to Automatically Delete Your YouTube History
  • › What Is “Mixed Content,” and Why Is Chrome Blocking It?

The xcopy command is a Command Prompt command used to copy one or more files or folders from one location to another location.

The xcopy command, with its many options and ability to copy entire directories, is similar to, but much more powerful than, the copy command.

The robocopy command is also similar to the xcopy command but has even more options.

Xcopy Command Availability

The xcopy command is available from within the Command Prompt in all Windows operating systems including Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows 98, etc. See How to Open Command Prompt if you need help.

The xcopy command is also a DOS command available in MS-DOS.

The availability of certain xcopy command switches and other xcopy command syntax may differ from operating system to operating system.

Xcopy Command Syntax

See How to Read Command Syntax if you're not sure how to read the xcopy command syntax above or in the table below.

The xcopy command will add the archive attribute to files in destination no matter if the attribute was on or off on the file in source.

Save the sometimes lengthy output of the xcopy command to a file using a redirection operator. See How to Redirect Command Output to a File for instructions or check out Command Prompt Tricks for more tips.

Xcopy Command Examples

In the above example, the files contained in the source directory of C:Files are copied to destination, a new directory [/i] on the E drive called Files.

No subdirectories, nor any files contained within them, will be copied because the /s option was not used.

In this example, the xcopy command is designed to function as a backup solution. Try this if you'd like to use xcopy instead of a backup software program to back up your files. Put the xcopy command as shown above in a script and schedule it to run nightly.

As shown above, the xcopy command is used to copy all the files and folders [/s] newer than those already copied [/d], including empty folders [/e] and hidden files [/h], from source of C:Important Files to the destination of D:Backup, which is a directory [/i]. We have some read-only files we want to keep updated in destination [/r] and we want to keep that attribute after being copied [/k]. We also want to make sure we maintain any ownership and audit settings in the files we're copying [/x]. Finally, since we're running xcopy in a script, we don't need to see any information about the files as they're copied [/q], We don't want to be prompted to overwrite each one [/y], nor do we want xcopy to stop if it runs into an error [/c].

Here, the xcopy command is used to copy all the files, subfolders, and files contained in the subfolders [/s] from source of C:Videos to the destination folder Media Backup located on a computer on the network by the name of SERVER. We're copying some really large video files, so buffering should be disabled to improve the copy process [/j], and since we're copying over the network, we want to be able to resume copying if we lose the network connection [/z]. Being paranoid, we want to be prompted to start the xcopy process before it actually does anything [/w], and we also want to see every detail about what files are being copied as they're being copied [/f].

In this final example, we have a source full of well organized files and folders in C:Client032 for a client. We've already created an empty destination folder, Client033, for a new client but we don't want any files copied — just the empty folder structure [/t] so that we're organized and prepared. We have some empty folders in C:Client032 that might apply to the new client, so we want to make sure those are copied as well [/e].

Xcopy & Xcopy32

In Windows 98 and Windows 95, two versions of the xcopy command were available: xcopy and xcopy32. However, the xcopy32 command was never intended to be run directly.

When you execute xcopy in Windows 95 or 98, either the original 16-bit version is automatically executed (when in MS-DOS mode) or the newer 32-bit version is automatically executed (when in Windows).

Windows 7 Copy File Cmd

To be clear, no matter what version of Windows or MS-DOS you have, always run the xcopy command, not xcopy32, even if it's available. When you execute xcopy, you're always running the most appropriate version of the command.

Xcopy Related Commands

The xcopy command is similar in many ways to the copy command but with significantly more options. The xcopy command is also very much like the robocopy command except that robocopy has more flexibility than even xcopy.

Windows Command Line Copy File

The dir command is often used with xcopy to check which folders and files are in a directory before completing the command.