1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Copy command to set timestamp not working in TCC/LE

Discussion in 'TCC/LE Support' started by bytecave, Jan 3, 2017.

  1. bytecave

    Joined:
    Jan 3, 2017
    Messages:
    2
    Likes Received:
    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!
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,079
    Likes Received:
    30
    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
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,358
    Likes Received:
    39
    You're aware that TCC/LE has an internal TOUCH, right?
     
  4. JohnQSmith

    Joined:
    Jan 19, 2011
    Messages:
    559
    Likes Received:
    7
    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
     
  5. bytecave

    Joined:
    Jan 3, 2017
    Messages:
    2
    Likes Received:
    0
    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!
     
    #5 bytecave, Jan 4, 2017
    Last edited: Jan 4, 2017
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,040
    Likes Received:
    84
    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.
     

Share This Page