Windows

Use the Copy as Path command to compensate for the missing drag and drop feature

If you’re like most IT folks, you use the command line to perform all kinds of tasks. However, there is one drawback to working from the command line that is exacerbated by long folder names -- changing from one folder, or directory, to another using the CD (Change Directory) command. In this edition of the Windows Vista Report, Greg Shultz shows you how to use the Copy as Path command as a replacement for the old drag and drop operation to save you some keystrokes when you are working in the command line.

If you're like most IT folks, you use the command line to perform all kinds of tasks. However, there is one drawback to working from the command line that is exacerbated by long folder names -- changing from one folder, or directory, to another using the CD (Change Directory) command. Not only is typing long folder names on the command line a lot of extra work, but one typo and you'll find yourself starting all over.

In this edition of the Windows Vista Report, I'll show you how to use the Copy as Path command as a replacement for the old drag and drop operation to save you some keystrokes when you are working in the command line.

If it ain't broke...

When long file and folders names were introduced back in the days of Windows 95, Microsoft introduced two methods that were designed to simplify working with long folder names from the command line.

The first method involved using a drag and drop operation in which you could drag a folder icon from Windows Explorer and drop it in a Command Prompt window in which you had already typed the CD command followed by a double quote ("). You could then just press [Enter] and you were in business. The second method involved installing and using a Power Toy called Open Command Prompt Here, with which you could right click on any folder and open a Command Prompt window in that folder.

As you may know, both the native drag and drop operation and separately installed Open Command Prompt Here Power Toy have been available in every Windows operating system since then -- until Windows Vista that is. Now, the renamed Open Command Window Here feature is built right into the operating system, which is definitely a plus; however, the drag and drop operation was 86ed. If you attempt to drag a folder from Windows Explorer and drop it in a Command Prompt window in Windows Vista, you'll see a Not Allowed symbol, similar to the one shown in Figure A.

Figure A

In Windows Vista dragging a folder and dropping it in a Command Prompt window is no longer allowed.

If, like me, you really got used to using drag and drop in a Command Prompt window, you found this omission in Windows Vista to be quite shocking the first time you encountered it. A handy feature that has been around for 12 years and five versions of Windows no longer works!

While I've not been able to find definitive answer on why Microsoft trashed the handy drag and drop operation, I have made due by taking advantage of the built-in Open Command Prompt Here feature. While not as slick, it does allow you to access deeply nested folders from the command line without having to type a lengthy path.

However, while recently using the Open Command Prompt Here feature, I was pining away for the drag and drop operation, when I discovered that a practical replacement was staring me right in the face the whole time -- hidden in plain sight. Of course, I'm talking about the Copy as Path command.

The Copy as Path command

The Copy as Path command appears on the context menu when you hold down the [Shift] key as you right click on a folder, as shown in Figure B. Keep in mind that this [Shift] + Right-Click combination only works when you use it in the right hand section of Windows Explorer -- it doesn't work in the Folders section on the left.

Figure B

You can access the Copy as Path command from the context menu when you use [Shift] + Right-Click combination in the main section of Windows Explorer.
Once you use the Copy as Path command, the entire path of the folder is copied to the clipboard. You can now select the Command Prompt window, type the CD command, press [Spacebar], and then right click anywhere inside the Command Prompt window. When you do, the entire path, already enclosed in double quotes is pasted on the command line, as shown in Figure C. You can then just press [Enter] and you instantly have access to that folder on the command line.

Figure C

Just right click in the Command Prompt window, and the path will be pasted on the command line.

While it may seem that this technique isn't as slick as the old drag and drop operation, I must admit that once you get used to it, it is every bit as fast as the old method. And, in many cases, it is a better alternative than using the Open Command Prompt Here feature.

Other uses

While the using the Copy as Path command is a handy aid when working in a Command Prompt window, it has other uses too. For example, suppose you need to send a link to a network share to a colleague via e-mail. All you have to do use the Copy as Path command, paste the path in the e-mail, and you have an instant shortcut that you can then send to your colleague. And, in addition to using the Copy as Path command to copy the path to a folder or network share, you can also copy the path to a file -- including the file name.

Another place the Copy as Path command comes in handy is when uploading files to a Web site. Instead of using browse dialog box to locate the file you want to upload, you can simply paste the path into the upload text box.

About

Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

19 comments
SharonF
SharonF

Thank you so much for highlighting this "hidden" command! For years on Windows XP, I have been using freeware called "rjhExtensions 1.3" which "is a simple utility that will add a number of useful functions to the context menu of Windows Explorer. Including a path to clipboard function, DOS prompt, file encryption, file renaming, a file shredder, file duplicator and functions". The feature that originally drew me to this freeware was the ability to save or print a directory file listing. It's available at http://www.rjhsoftware.com/products.html I use the path to clipboard utility for many of the other uses mentioned in the article, as well as to simply open a file from an application's Open window by pasting the file path into the File name box (Ctrl-o, Ctrl-v, Enter). Unfortunately, I don't expect rjh will be updating the freeware for Vista, so the Copy As Path command will be a critical tool for me. Although I can understand why the Copy As Path command adds the double-quotes on each end, my Backspace, Home and Delete keys will get a workout.

junk
junk

It's like playing twister! Right hand SHIFT, left hand RIGHT CLICK. The easiest way is to simply click on the address bar, which immediately reverts to a normal path, and type CONTROL-C. At least it's all one-handed. I still sorely miss the Cut/Copy/Paste buttons on the toolbar. Why did Microsoft eliminate these? They should at least be a customizable option. Dumb!

erioll
erioll

u could also write a few letters of the folder/file you want and press TAB key (keep pressing the key if u want other names)

groon
groon

While the "Copy as Path" is an interesting little toy, I can't help wondering why you didn't mention tab completion in your article. Most command prompt folks I know enter cd and press to cycle through the directories and hit when they hit the desired target. Better still, enter cd and you're their quicker. E.G. Suppose you're in your %UserProfile% folder. Enter: cd a and you'll probably get "application data" straight away. While "copy as path" might be a timesaver for hitting deeply-nested folders, tab completion is much more efficient for most directory changing, and it's been around forever.

?/\/\?|???\/???
?/\/\?|???\/???

>> While I?ve not been able to find definitive answer on why Microsoft trashed the handy drag and drop operation

heislyc
heislyc

Did u mean after Copy as Path, straight away Right Click on command prompt windows will instantly auto-Paste the path into the command line? It doesn't work for me, I need to Right Click(Menu) > Paste to proceed... Why? (Doesn't work if I "Run as Administrator" too)

SharonF
SharonF

"The easiest way is to simply click on the address bar, which immediately reverts to a normal path, and type CONTROL-C. At least it's all one-handed." That works fine to get the directory, but it doesn't get the filename.

jruby
jruby

Going thru the contortions of shift right-click does allow you to include the selected file as part of the path instead of just the foldername, but yeah, I'm still mad that the Cut/Copy/Paste buttons were taken away. Jim /Upgrading from Vista to XP this weekend. Yipee!/

george.gordon
george.gordon

As a non-expert, both "Copy as Path" and "Tab Completion" are new to me, so thanks. I guess my favorite (quick and not so cool?) method will be known to you all. Look in Properties of a Command Prompt shortcut. On the Shortcut tab, delete whatever is in "Start in" - it will usually be "%HOMEDRIVE%%HOMEPATH%". Close Properties. If you then drop a copy of this modified Command Prompt in any folder, it will operate on that folder. I find this very useful if you have a folder structure created to hold project data for various categories or dates, and need to perform the same or similar operations on each sub-folder. Just move your Command Prompt around the folders and hey presto!

Greg Shultz
Greg Shultz

You are corect in that you can indeed perform the same type of operation using Tab Completion, which is a very cool trick. However, as you know, in the Windows Operating System there are always more than one way to skin the cat (so to speak). Since the focus of this tip is how the Copy As Path command can be used as a replacement for the the old drag and drop operation, I did not mention the Tab Completion technique.

elnator
elnator

But the place I've found 'copy as path' to be most useful is when trying to run an application as admin. The function works on the task bar and in the start menu as well, not just in Windows Explorer. So if you need to run, say, Active Directory Users & Computers and a bunch of other crud with admin rights you can just copy as path them into a command prompt you've already opened with admin rights and launch them that way, thus avoiding having to enter credentials a zillion times, especially if you haven't turned off the nag feature within VISTA.

mb.techrepublic
mb.techrepublic

I agree entirely with its use - tab completion is very useful (probably why the idea was taken from *NIX shells? Ha ha) I was about to say that I wasn't not sure about its having "been around forever", but I just thought I'd check for W2000/W2K and I see that although not on by default, directory and filename completion can be turned on (CMD/EXE /F:ON) or by doing a reg hack (check out CMD /?). On W2000, I'd always used something like "CD \W*" which would CD to the first directory starting with W. I seem to recall that works on other pre-XP systems too, but I don't remember which ones (there aren't too many of those left now, eh?)

sleach
sleach

I totally agree with Groon on this, I work for a large IT company and all of the developers & testers I work with use tab compete, it's a no brainer.... I also wondered why this technique was not even mentioned as an alternative?

bbonesnew
bbonesnew

you can also select multiple files or folders with shift or ctrl-click and then get a nice file listing from it by using "copy as path" and then pasting it into an editor.

uvbogden
uvbogden

In Vista when opening a command prompt window, the command prompt is right-clicked and Run As Administrator is selected. Copy As Path or tab completion can then be used running as administrator. When accessing the command prompt window from shift/right-click Open Command Window on a folder, is this running as administrator?

Aakash Shah
Aakash Shah

SharonF: That is true. Here are two keyboard alternatives that I personally use to get around this problem: 1.Click "alt+d" to get to the address bar and then hit "end" and then use "shift+ctrl+left arrow" to select the file name. 2.If the focus is in the explorer window, then click "F2" to activate the rename feature which will select the entire file name. Then click "ctrl+c" to select the file name. Note that I have viewing extensions turned off so if you don't, you will need to de-select the extension (in Windows Vista, the rename feature automatically selects only the filename and not the extension).

Aakash Shah
Aakash Shah

Try this: while in the explorer window, click alt+d to get to the address bar and select the path and then hit ctrl+c. This should allow you to use the copy/paste operation you are interested in. Also, you only need one hand to accomplish this.

elnator
elnator

No it doesn't. You will need to use the 'copy as path' function and paste it into a command prompt that's been opened with admin rights.