General discussion

  • Creator
    Topic
  • #2279583

    copy a file to the current date in NT

    Locked

    by jrosalia ·

    I would like to know if it is possible to copy a file in DOS on a WINNT workstation to the current date. I tried %date% and it did not work. If not in DOS, how about in C ? I have an old copy of a C compiler for Dos. Thanks

All Comments

  • Author
    Replies
    • #3364267

      Reply To: copy a file to the current date in NT

      by joseph moore ·

      In reply to copy a file to the current date in NT

      Wait a sec. Let me make sure I understand your question.

      Are you asking how to copy a file, and have the file name of the copy be the current date? If so, here is how.

      Say you want to copy C:\Temp\FILE1.TXT into C:\Backup with a filename of 10-15-2003.txt

      This BAT file will do it:


      @echo
      off
      c:
      cd\
      cd temp
      for /f “tokens=1-4 delims=: ” %%i in (‘date /t’) do set nowdate=%%j-%%k-%%l
      copy FILE1.TXT C:\Backup\%nowdate%.txt
      EXIT

    • #3364777

      Reply To: copy a file to the current date in NT

      by jrosalia ·

      In reply to copy a file to the current date in NT

      This question was closed by the author

Viewing 1 reply thread