Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Copy command to set timestamp not working in TCC/LE

Jan
2
0
What with Windows 10 about get rid of CMD.Exe, I've switched everything to your lovely TCC/LE, thanks for making it!

I have certain batch files that use an obscure copy command to set timestamp of a file:

copy <filename.ext> + <filename.ext> /y

This returns right away in cmd.exe with the only result being the updated timestamp on <filename.ext>. I get a "Contents lost before copy" error with TCC/LE.

Now, this might happen because TCC/LE fixed some sort of copy bug that I've been exploiting for awhile, and I know that I can just download a touch.exe. Reporting it just in case it's a compatibility oversight. Thanks again!
 
That doesn't seem to work very well in Win 7's CMD. It adds 1 byte to the file!
Code:
V:\> dir v*
 Volume in drive V is DATA
 Volume Serial Number is C007-D3E4

 Directory of V:\

2017-01-03  20:59                18 var.txt
               1 File(s)             18 bytes
               0 Dir(s)   8,890,716,160 bytes free

V:\> copy var.txt + var.txt /y
var.txt
        1 file(s) copied.

V:\> dir v*
 Volume in drive V is DATA
 Volume Serial Number is C007-D3E4

 Directory of V:\

2017-01-03  21:01                19 var.txt
               1 File(s)             19 bytes
               0 Dir(s)   8,890,716,160 bytes free
 
It adds 1 byte to the file!
You also need to add a /b to the command, otherwise it adds a ctrl-z character.
Code:
C:\temp>dir v*
 Volume in drive C has no label.
 Volume Serial Number is 262B-D729

 Directory of C:\temp

01/04/2017  09:16 AM             1,279 var.txt
               1 File(s)          1,279 bytes
               0 Dir(s)  111,927,558,144 bytes free

C:\temp>copy var.txt + var.txt /y /b
var.txt
        1 file(s) copied.

C:\temp>dir v*
 Volume in drive C has no label.
 Volume Serial Number is 262B-D729

 Directory of C:\temp

01/04/2017  09:16 AM             1,279 var.txt
               1 File(s)          1,279 bytes
               0 Dir(s)  111,927,554,048 bytes free
 
Well... wow. Somewhere back in time, the command "copy filename + ," (best as I recall from memory) stopped working as a touch command. I "brilliantly" figured out that copy filename.txt + filename.txt /y /b (my scripts do in fact have a /b switch, oops. edit: more wrongness. no, in fact, they don't. i want to hide under a rock) did the trick. For around 20 years, I have never noticed that it was adding a byte to the file. The files in my batch files are sentinel files for processing data, so their content has always been less important then the timestamp. I apologize for the randomization. The only thing not working properly here. . . is me!
 
Last edited:
If you use the internal TOUCH command with no time or date:

touch var.txt

it will set the date / time of var.txt to the current date & time.

I'm aware of the undocumented CMD behavior (though IMO it should be classified as a bug, not a feature). Given that it's a more complicated approach than using TOUCH, and that it would hide an error that was more likely the intent, I never deemed it worth duplicating.
 

Similar threads

Back
Top