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 8062 times)

0 Members and 1 Guest are viewing this topic.

Esgrimidor

    Topic Starter


    Hopeful

    Thanked: 1
    Places utility with variables
    « on: June 30, 2012, 08:41:48 AM »
    I am using this utility Places

    then I locate this personalization in the windows registry

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\ComDlg32\PlacesBar

    And try to personalize the folders with environment variables

    But I can't

    How can I do ?

    I need than when edit the key I can propose path with variables like :

    Y:\crono\2012\06.2012\%date%

    How can I format the environment variable %date% ?

    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 #1 on: June 30, 2012, 11:52:23 AM »
    The date variable is dependent on your regional settings. Can you please show us the output of the date variable from the cmd prompt.

    Esgrimidor

      Topic Starter


      Hopeful

      Thanked: 1
      Re: Places utility with variables
      « Reply #2 on: June 30, 2012, 11:58:22 AM »
      It's not possible use directly the output of %DATE%.

      And I can't vary without affecting other programs I have.

      What I need is reformat the output to the criteria : yyyy  2012
      mm 06
      dd 30

      By example 30.06.2012
      In my system the default configuration I can't change is 30/06/2012

      Best Regards

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

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: Places utility with variables
      « Reply #3 on: June 30, 2012, 12:27:09 PM »
      if you want to expand environment variables use the REG_EXPAND_SZ registry data type instead of the REG_SZ type. Unfortunately I think the program accessing those values would still be using REG_SZ as the data type.
      I was trying to dereference Null Pointers before it was cool.

      carlsomo



        Rookie

        • Experience: Beginner
        • OS: Unknown
        Re: Places utility with variables
        « Reply #4 on: June 30, 2012, 01:41:01 PM »
        if %date% is 30/06/2012 and you want 30.06.2012 then
        set today=%date:/=.%
        echo %today%
        30.06.2012

        or if you want yyyy, mm, dd in variables then
        set yyyy=%date:~0,4%
        set mm=%date:~5,2%
        set dd=%date:~8,2%
        set today=%yyyy%.%mm%.%dd%

        the above will work if the %date% variable is always in that format (yyyyy/mm/dd)
        it gets more complicated if you want code to handle any common format
        it gets more complicated if you (or your user) does not have admin access to the registry
        I have the batch code done to do all this if anyone is interested

        Esgrimidor

          Topic Starter


          Hopeful

          Thanked: 1
          Re: Places utility with variables
          « Reply #5 on: June 30, 2012, 02:55:34 PM »
          if %date% is 30/06/2012 and you want 30.06.2012 then
          set today=%date:/=.%
          echo %today%
          30.06.2012

          or if you want yyyy, mm, dd in variables then
          set yyyy=%date:~0,4%
          set mm=%date:~5,2%
          set dd=%date:~8,2%
          set today=%yyyy%.%mm%.%dd%

          the above will work if the %date% variable is always in that format (yyyyy/mm/dd)
          it gets more complicated if you want code to handle any common format
          it gets more complicated if you (or your user) does not have admin access to the registry
          I have the batch code done to do all this if anyone is interested

          Can you put the link to your batch
          I am interested.

          Best Regards

          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 #6 on: June 30, 2012, 02:57:10 PM »
            Anyone with xp pro sp3 windows system can see the key

            I think the Places utilities only take advantage of the prior existence of those keys standard configurated by the OS.

            So are alfa numerical keys.
            No dejes que tu felicidad dependa de lo que no depende de tí.

            carlsomo



              Rookie

              • Experience: Beginner
              • OS: Unknown
              Re: Places utility with variables
              « Reply #7 on: June 30, 2012, 03:09:26 PM »
              @echo off&SetLocal EnableDelayedExpansion&goto :start
              :GetDate [EnVar]
              echo.GetDate [EnVar] Sets date into environment variable, EnVar as: mm-dd-yyyy
              echo.Usage: GetDate mdy^&set ymd=%%errorlevel%%, ^(use %% rather than ^^! in command line)
              echo.Usage: GetDate mdy^&set ymd=^^!errorlevel^^!, ^(use ^^! rather than %% in script^)
              echo.If no argument passed it echo's the date in mm-dd-yyyy format
              echo.Returns yyyymmdd 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 %yy% lss 100 set "yy=20%yy%"
              if defined p1 (
                Endlocal
                call set "%~1=%mm%-%dd%-%yy%"&exit /b %yy%%mm%%dd%
              )
              EndLocal&echo.%mm%-%dd%-%yy%&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 #8 on: June 30, 2012, 03:28:46 PM »
                Going to study

                Best Regards

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

                carlsomo



                  Rookie

                  • Experience: Beginner
                  • OS: Unknown
                  Re: Places utility with variables
                  « Reply #9 on: June 30, 2012, 03:36:08 PM »
                  Let me know if you find any bugs in it!

                  I have only tested it in US English formats

                  Esgrimidor

                    Topic Starter


                    Hopeful

                    Thanked: 1
                    Re: Places utility with variables
                    « Reply #10 on: June 30, 2012, 03:50:43 PM »
                    That's is going to be my problem.

                    I need in spanish format

                    dd.mm.yyyy
                    mm.yyyy
                    yyyy

                    What can I do ?

                    I don't understand much the batch language .....

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

                    carlsomo



                      Rookie

                      • Experience: Beginner
                      • OS: Unknown
                      Re: Places utility with variables
                      « Reply #11 on: June 30, 2012, 04:12:00 PM »
                      if you type:
                      C:\>date
                      at the dos prompt with Spanish settings, ie as if you wished to review or change the date what is displayed?

                      for example in US English:
                      C:\>date
                      The current date is: Sat 06/30/12
                      Enter the new date: (yy-mm-dd)

                      Also, if you type date/t  at the dos prompt in spanish what do you get?

                      for example in US English:
                      C:\>date/t
                      Sat 06/30/12

                      if I could see the spanish output from those commands I think I could modify the code to suit your needs
                      regards

                      Squashman



                        Specialist
                      • Thanked: 134
                      • Experience: Experienced
                      • OS: Other
                      Re: Places utility with variables
                      « Reply #12 on: June 30, 2012, 04:48:29 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.

                      carlsomo



                        Rookie

                        • Experience: Beginner
                        • OS: Unknown
                        Re: Places utility with variables
                        « Reply #13 on: June 30, 2012, 04:52:41 PM »
                        I think you can modify my batch script by changing these lines:

                        if defined p1 (
                          Endlocal
                          call set "%~1=%mm%-%dd%-%yy%"&exit /b %yy%%mm%%dd%
                        )
                        EndLocal&echo.%mm%-%dd%-%yy%&exit /b %yy%%mm%%dd%

                        to this:

                        if defined p1 (
                          Endlocal
                          call set "%~1=%yy%.%mm%.%dd%"&exit /b %yy%%mm%%dd%
                        )
                        EndLocal&echo.%yy%.%mm%.%dd%&exit /b %yy%%mm%%dd%

                        then if you put this in your batch:
                        call getdate.bat ymd
                        echo %ymd%
                        you will get 2012.06.30 stored in the ymd varaible

                        set yyyy=%ymd:~0,4%
                        set mm=%ymd:~5,2%
                        set dd=%ymd:~8,2%

                        now yyyy=2012
                        mm=06
                        dd=30

                        set folder=%yyyy%.%mm%
                        echo \%folder%\myfile.dat
                        \2012.06\myfile.dat

                        does this help??

                        Esgrimidor

                          Topic Starter


                          Hopeful

                          Thanked: 1
                          Re: Places utility with variables
                          « Reply #14 on: June 30, 2012, 07:26:14 PM »
                          if you type:
                          C:\>date
                          at the dos prompt with Spanish settings, ie as if you wished to review or change the date what is displayed?

                          for example in US English:
                          C:\>date
                          The current date is: Sat 06/30/12
                          Enter the new date: (yy-mm-dd)

                          Also, if you type date/t  at the dos prompt in spanish what do you get?

                          for example in US English:
                          C:\>date/t
                          Sat 06/30/12

                          if I could see the spanish output from those commands I think I could modify the code to suit your needs
                          regards

                          The screenshot with the commands



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