Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I wrote the following command in windows XP's command shell and something strange happened:

C:\Folder1> copy sample.txt :

Because of my typing mistake, I wrote ":" instead of "D:"

... but it copied the sample.txt to somewhere I cant find!

I searched my whole HDD for sample.txt but the only instance of this file is the original one which is in C:\Folder1.

Do you know where ":" path actually is in Win-XP command shell?

You might say ":" is current path and the file has been copied onto itself but look at this:

If you run that command for the first time, this will be the result:

1 file copied.

but the next time you run that command it will ask you:

overwrite sample.txt? (yes/no/all)

So if it were writing the file onto itself, both results would have to be the same but they aren't.

Thanks in advance for your help.

share|improve this question
    
Why is this question considered off topic? Others concerning "batch" programming, which arguably is the case here, are not. –  Christian.K Oct 20 '12 at 19:43
add comment

migrated from stackoverflow.com Oct 20 '12 at 21:38

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 4 down vote accepted

Your data was copied into a NTFS Alternate Data Stream attached to the current directory.

There are tools (e.g. ADSRevealer) that would allow you to verify that . has now indeed an ADS attached.

If you type:

MORE < :sample.txt

you will retrieve the copy of sample.txt.

For more information see e.g. here. Keep in mind that command line support for ADS in XP is 'immature' at best.

share|improve this answer
    
So you are saying that "copy sample.txt :" is essentially a shortcut for "copy sample.txt sample.txt:streamname"? Whatever streamname in particular than is. For the live of me I could not find a reference for that on the net (and I don't have a windows box right now to try it out). –  Christian.K Oct 20 '12 at 20:11
    
Sorry. My bad. I got it wrong. It is not sample.txt that acquires the ADS, but the directory itself; and it acquires an ADS called sample.txt. Updating answer. –  lserni Oct 20 '12 at 20:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.