Using xp date variable to name a file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Geezer
    New Member
    • Feb 2007
    • 2

    Using xp date variable to name a file

    I need to know how to name an output file in XP so that the file name looks like the following:

    02/14/2007.qic

    Can I use the %date% variable and how would I do it?
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by Geezer
    I need to know how to name an output file in XP so that the file name looks like the following:

    02/14/2007.qic

    Can I use the %date% variable and how would I do it?
    Are you write DOS batch files or using some other programming language. Once we have that info, we will know which forum this actually belongs in.
    Thanks for joining TSDN!

    Comment

    • Geezer
      New Member
      • Feb 2007
      • 2

      #3
      Originally posted by bartonc
      Are you write DOS batch files or using some other programming language. Once we have that info, we will know which forum this actually belongs in.
      Thanks for joining TSDN!

      Am familiar with DOS, and windows XP.
      Suggest a direction and I will do the research.

      I wish to name an output file from a backup program using the current date as follows:

      xx/xx/xxxx.qic

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by Geezer
        Am familiar with DOS, and windows XP.
        Suggest a direction and I will do the research.

        I wish to name an output file from a backup program using the current date as follows:

        xx/xx/xxxx.qic
        Can you tell us more about the back-up program?

        Comment

        • ghostdog74
          Recognized Expert Contributor
          • Apr 2006
          • 511

          #5
          Originally posted by Geezer
          I need to know how to name an output file in XP so that the file name looks like the following:

          02/14/2007.qic

          Can I use the %date% variable and how would I do it?
          first you have to know what your output of 'date /t' is like.
          On my machine its Tue 02/13/2007
          then using for loop
          Code:
          @echo off
          for /F "tokens=1,2 delims= " %%i in ('date /t') do (
          	echo %%j
          	echo test > %%j.qic
          )
          )

          Comment

          • maxamis4
            Recognized Expert Contributor
            • Jan 2007
            • 295

            #6
            Make it easy on your self, why not just name 02-13-2007

            Comment

            • Cyberdyne
              Recognized Expert Contributor
              • Sep 2006
              • 627

              #7
              can't use / character file name, sorry. use - or . instead, good luck!

              Comment

              • ghostdog74
                Recognized Expert Contributor
                • Apr 2006
                • 511

                #8
                yes,"/" can't be used..so it should be something like this
                Code:
                @echo off
                for /F "tokens=1,2 delims= " %%i in ('date /t') do (
                	 echo %%j
                	 for /F "tokens=1,2,3 delims=/" %%a in ("%%j") do echo test>%%a-%%b-%%c.qic
                )

                Comment

                • trigon
                  New Member
                  • May 2007
                  • 1

                  #9
                  In addition to this, if you want (with DOS command) to copy file 1.csv to file 2.csv where file 2.csv should have a DATE name (only month and year) what command I should use.

                  Thank you in advance

                  Comment

                  Working...