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

Author Topic: Places utility with variables  (Read 8070 times)

0 Members and 1 Guest are viewing this topic.

Esgrimidor

    Topic Starter


    Hopeful

    Thanked: 1
    Re: Places utility with variables
    « Reply #15 on: June 30, 2012, 07:28:22 PM »
    It would be really great if you could actually shows us the output of this following from the command prompt.
    Code: [Select]
    C:\>echo %date%
    Sat 06/30/2012

    C:\>
    There is a way to make this regionally independent.  It is a ton of of code though to add to your batch file.

    The screenshot with the command line



    [year+ old attachment deleted by admin]
    No dejes que tu felicidad dependa de lo que no depende de tí.

    Esgrimidor

      Topic Starter


      Hopeful

      Thanked: 1
      Re: Places utility with variables
      « Reply #16 on: June 30, 2012, 07:29:25 PM »
      I'll for your advice after revising the screenshots

      Best Regards
      No dejes que tu felicidad dependa de lo que no depende de tí.

      Squashman



        Specialist
      • Thanked: 134
      • Experience: Experienced
      • OS: Other
      Re: Places utility with variables
      « Reply #17 on: July 01, 2012, 12:34:11 PM »
      There is no need to post screen shots for the output of the cmd line or batch files. You can copy and paste the text from the cmd window into the forums. Posting an image just consumes more resources.

      carlsomo



        Rookie

        • Experience: Beginner
        • OS: Unknown
        Re: Places utility with variables
        « Reply #18 on: July 08, 2012, 11:37:30 PM »
        this should work in spanish but if there is an option to put the month in three letter version then change jan feb mar, etc to the spanish version in the script below:

        @echo off&SetLocal EnableDelayedExpansion&goto :start
        :GetDate [EnVar]
        echo.GetDate [EnVar] Sets date into environment variable, EnVar as: dd-mm-aaaa
        echo.Usage: GetDate dma^&set ymd=%%errorlevel%%, ^(use %% rather than ^^! in command line)
        echo.Usage: GetDate dma^&set ymd=^^!errorlevel^^!, ^(use ^^! rather than %% in script^)
        echo.If no argument passed it echo's the date in dd-mm-aaaa format
        echo.Returns aaaammdd in errorlevel regardless if Envar is passed as argument or not
        echo.Works on NT/2K/XP/Vista/Win7 machines independent of most regional date settings
        EndLocal&exit /b

        :start
        set p1=%~1&if /i "!p1!" equ "/?" goto :GetDate
        if /i "%date%A" lss "A" (set toks=1-3) else (set toks=2-4)
        for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('date^<nul') do (
          for /f "tokens=%toks% delims=.-/ " %%d in ('date/t') do (
            set %%a=%%d&set %%b=%%e&set "%%c=%%f"
          )
        )
        if /i "%mm:~0,1%" gtr "9" call :month_convert mm
        if /i 1%mm% lss 20 set "mm=0%mm%"
        if /i %aa% lss 100 set "aa=20%aa%"
        if defined p1 (
          Endlocal
          call set "%~1=%dd%-%mm%-%aa%"&exit /b %yy%%mm%%aa%
        )
        EndLocal&echo.%dd%-%mm%-%aa%&exit /b %yy%%mm%%dd%

        :month_convert
        set "months=Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"
        call set "month=%%%~1%%"
        set/a mnum=0
        for %%m in (%months%) do set/a mnum+=1&if /i %month% equ %%m call set "%~1=!mnum!"&exit /b

        Esgrimidor

          Topic Starter


          Hopeful

          Thanked: 1
          Re: Places utility with variables
          « Reply #19 on: July 12, 2012, 05:43:07 PM »
          this should work in spanish but if there is an option to put the month in three letter version then change jan feb mar, etc to the spanish version in the script below:

          @echo off&SetLocal EnableDelayedExpansion&goto :start
          :GetDate [EnVar]
          echo.GetDate [EnVar] Sets date into environment variable, EnVar as: dd-mm-aaaa
          echo.Usage: GetDate dma^&set ymd=%%errorlevel%%, ^(use %% rather than ^^! in command line)
          echo.Usage: GetDate dma^&set ymd=^^!errorlevel^^!, ^(use ^^! rather than %% in script^)
          echo.If no argument passed it echo's the date in dd-mm-aaaa format
          echo.Returns aaaammdd in errorlevel regardless if Envar is passed as argument or not
          echo.Works on NT/2K/XP/Vista/Win7 machines independent of most regional date settings
          EndLocal&exit /b

          :start
          set p1=%~1&if /i "!p1!" equ "/?" goto :GetDate
          if /i "%date%A" lss "A" (set toks=1-3) else (set toks=2-4)
          for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('date^<nul') do (
            for /f "tokens=%toks% delims=.-/ " %%d in ('date/t') do (
              set %%a=%%d&set %%b=%%e&set "%%c=%%f"
            )
          )
          if /i "%mm:~0,1%" gtr "9" call :month_convert mm
          if /i 1%mm% lss 20 set "mm=0%mm%"
          if /i %aa% lss 100 set "aa=20%aa%"
          if defined p1 (
            Endlocal
            call set "%~1=%dd%-%mm%-%aa%"&exit /b %yy%%mm%%aa%
          )
          EndLocal&echo.%dd%-%mm%-%aa%&exit /b %yy%%mm%%dd%

          :month_convert
          set "months=Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"
          call set "month=%%%~1%%"
          set/a mnum=0
          for %%m in (%months%) do set/a mnum+=1&if /i %month% equ %%m call set "%~1=!mnum!"&exit /b

          I'll try .
          Best Regards
          No dejes que tu felicidad dependa de lo que no depende de tí.