Helping people with computers... one answer at a time.
Windows Explorer is a fine tool, but there are still a few things you can't easily do with it. This calls for the Windows Command Prompt.
I would like to be able to copy a file but at the same time rename it, so when it gets to the destination folder it has whatever file name I want it to. Do you know of a way to accomplish this in one step?
Not using Windows Explorer, no.
However it's a snap using the Windows Command Prompt.
In Windows Explorer, when you drag and drop a file from one location to another, you must let the copy (or move) operation complete before you can then rename the file in its new location.
However, using the COPY command in the Windows Command Prompt, you can do it in one quick step.
Start by firing up a command prompt - usually Start, All Programs, Accessories, Command Prompt. You'll probably get something like this:
The COPY command has the following syntax:
COPY source destination
The "trick" here, if you want to call it that, is that the destination can either be the folder to receive the file, or it can include the new filename.
copy current.txt "My Documents"
Executed with "C:\Documents and Settings\LeoN" as the current directory, copied "C:\Documents and Settings\LeoN\current.txt" to "C:\Documents and Settings\LeoN\My Documents\current.txt".
Now, this time we'll specify a filename:
This time we copied "C:\Documents and Settings\LeoN\current.txt" to "C:\Documents and Settings\LeoN\My Documents\copy.txt". In other words we copied the file, and gave the copy a new name in one operation.
These examples all assumed that the file you want to copy is in the "current directory" (or current folder), as listed in the command prompt itself. You can change directories with the "CD" command:
Now your COPY operations will be relative to the new current directory.
Alternatively the COPY command will work with full paths as well, eliminating any reliance on the current directory:
This example performed the same copy-and-rename we did earlier, but doesn't rely on any assumptions about the current directory. It specifies a full path to both the source and destination.
As you can imagine, the Command Prompt, while somewhat arcane for the average user, is incredibly powerful. Depending on your plans, it could be well worth spending a little time learning more about.
Comments on this entry are closed.
If you have a question, start by using the search box up at the top of the page - there's a very good chance that your question has already been answered on Ask Leo!.
If you don't find your answer, head out to http://askleo.com/ask to ask your question.