General discussion

  • Creator
    Topic
  • #2187312

    COPY Command in DOS

    Locked

    by naseemi ·

    Hi,

    I wish to copy a file (C:\DIRECTORY1\FILE1.TXT) to another subdirectory but with the current date appended to the filename (C:\DIRECTORY2\FILE1_20APR2005.TXT)

    Is there a way to do this type of file copy using the COPY command (or any other) in DOS? I want to write this into a batch file as a form of backup process.

    Please email me at : naseemi@webmail.co.za

    Many thanks in advance

    Naseem

All Comments

  • Author
    Replies
    • #3249128

      Reply To: COPY Command in DOS

      by pryzhkov ·

      In reply to COPY Command in DOS

      If You set in Your batch file something like:

      SET CC=%DATE:~4,2%-%DATE:~7,2%-%DATE:~10,4%

      it will give You the value of current date,
      i. e. 04-20-2005. So You can use it to change the name of Your file…

    • #3244636

      Reply To: COPY Command in DOS

      by deveshpradhan ·

      In reply to COPY Command in DOS

      Try this
      SET CC=%DATE:~0,2%%DATE:~3,2%%DATE:~6,4%
      COPY C:\DIRECTORY1\FILE1.TXT C:\DIRECTORY1\FILE1.TXT_%CC%

      This will create a file named FILE1.TXT_22042005
      in the C:\DIRECTORY1 folder.

      Hope this helps you.

      Good Luck

    • #3244991

      Reply To: COPY Command in DOS

      by naseemi ·

      In reply to COPY Command in DOS

      Thanks guys!
      All sorted out!
      Much appreciated

Viewing 2 reply threads