Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: NT Batch File  (Read 10672 times)

0 Members and 1 Guest are viewing this topic.

s2nrbald

    Topic Starter


    Starter

    • Experience: Beginner
    • OS: Unknown
    NT Batch File
    « on: October 11, 2010, 02:59:14 AM »
    Hello, I am looking to add a right click option to the file explorer in Windows NT, to copy a file and add the date. For example,

    before:
    copy.txt

    after:
    copy.txt
    copy_20101009.txt

    I have no idea how the batch file should look although I know the very basics how to create one. Can anyone help?

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: NT Batch File
    « Reply #1 on: October 11, 2010, 07:55:13 AM »
    Dates come is various formats, so please run echo %date% at the command line and post the results. This will better help us craft a batch file specifically for you.

    Attaching items to the context menu involves a registry hack which I do not recommend.  An alternative would be a batch file with a shortcut on the desktop. You could then drag and drop single or multiple files on the shortcut and produce the same results.

    Let us know.  8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    s2nrbald

      Topic Starter


      Starter

      • Experience: Beginner
      • OS: Unknown
      Re: NT Batch File
      « Reply #2 on: October 11, 2010, 09:05:13 AM »
      Thank you for your fast response.  My date format is "11.10.2010".  I do not necessarily need a registry hack, any fast solution is ok for me. 

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: NT Batch File
      « Reply #3 on: October 11, 2010, 09:43:42 AM »
      Can't remember exactly what batch language looked like in WinNT, but this little snippet might work as drag and drop: No registry hack involved.

      Code: [Select]
      @echo off
      set today=%date:~6,4%%date:~3,2%%date:~0,2%

      :loop
        copy %1 %~dpn1_%today%%~x1
        if .%2==. goto end
        shift
        goto loop

      :end

      Save the code as a batch file in the directory of your choice. Create a shortcut to the file on your desktop. You can then drag and drop file(s) from Windows Explorer on to the shortcut to create copies with todays date. You can also run the batch file from the command line passing a file name(s) on the command line to get the same results.

      Good luck.  8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      s2nrbald

        Topic Starter


        Starter

        • Experience: Beginner
        • OS: Unknown
        Re: NT Batch File
        « Reply #4 on: October 12, 2010, 12:09:22 AM »
        Looks like it works but not with file names that have a space in them.  Any ideas?

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: NT Batch File
        « Reply #5 on: October 12, 2010, 05:35:49 AM »
        Looks like it works but not with file names that have a space in them.  Any ideas?

        Always have ideas. Quoting the file names should be all you need.

        Code: [Select]
        @echo off
        set today=%date:~6,4%%date:~3,2%%date:~0,2%

        :loop
          copy "%1" "%~dpn1_%today%%~x1"
          if .%2==. goto end
          shift
          goto loop

        :end

        Good luck.  8)
        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein

        s2nrbald

          Topic Starter


          Starter

          • Experience: Beginner
          • OS: Unknown
          Re: NT Batch File
          « Reply #6 on: October 12, 2010, 06:42:21 AM »
          Hi player around with the quotes a little and got this to work:

          @echo off
          set today=%date:~6,4%%date:~3,2%%date:~0,2%

          :loop
            copy %1 "%~dpn1_%today%%~x1"
            if .%2==. goto end
            shift
            goto loop

          :end

          THANKS!