something strange about Win-XP's command shell

6

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.

user1762055

Posted 2012-10-20T19:30:29.100

Reputation:

Why is this question considered off topic? Others concerning "batch" programming, which arguably is the case here, are not. – Christian.K – 2012-10-20T19:43:13.333

Answers

4

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.

LSerni

Posted 2012-10-20T19:30:29.100

Reputation: 7 306

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 – 2012-10-20T20:11:30.807

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. – None – 2012-10-20T20:19:45.857