Environment Variables w/ Command Extensions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sakima
    Visitor
    • Sep 2008
    • 7

    Environment Variables w/ Command Extensions

    I was delighted when BC3 added the ability for sessions to use environment variables. For example,
    left folder %userprofile%
    right side d:\backups\%username%
    When opening the session, the environment variables are expanded into the correct paths and the folder comparison is performed. Beautiful!

    Is there any chance this capability could be expanded to use Command Extensions in Windows? For example:

    With Command Extensions enabled, %date:~0,3% gives the first three characters of the %date%, thus returning the day of week (Sun, Mon, Tue, etc.) This would allow having a *single* session that would work for each day of the week:
    left folder c:\some_folder
    right folder d:\backups\%date:~0,3%

    I currently accomplish this by running a batch file in which I set an environment variable as follows:
    set dow=%date:~0,3%
    In the batch file, I also assign a data directory and a backup directory. Then, in a beyond compare script, I use something like this:
    load %data_dir%\ %backup_dir%\%dow%\
    Works great! The trouble is that sometimes I want to view the same comparison interactively using a saved session. I've found no other way to do it but to create 7 sessions -- one for each day of the week. It works, and since I once the sessions are setup, it's not too bad unless I want to changes the name filters (or something else) in ALL 7 sessions.

    As noted above, Command Extensions would allow one session to handle the current day as determined by the environment.

    Thanks for you consideration.

    Kind regards,

    Rick
  • Aaron
    Team Scooter
    • Oct 2007
    • 16017

    #2
    Hello Rick,

    BC3's command line allows you to pass in variables, similar to a bat file. For example, you could use:
    bcompare.exe "@c:\script.txt" "%date:~0,3%"

    In the script you can then refer to this text with %1:
    load "c:\folder" "c:\folder\%1"
    expand all
    etc

    If the folder does not exist, you will get an error loading the base folders, but the text itself should be passed in without the need to set %dow%.

    How does this work for you?
    Aaron P Scooter Software

    Comment

    • Aaron
      Team Scooter
      • Oct 2007
      • 16017

      #3
      I should add that you can have multiple variables on the command line, each referenced in turn by their order: %1, %2, %3, etc.

      Documentation is in the Help file in the Using Beyond Compare -> Automating with Script chapter.
      Aaron P Scooter Software

      Comment

      • sakima
        Visitor
        • Sep 2008
        • 7

        #4
        Thank you for your replies, Aaron.

        As noted in my original post, I do use the batch file and script capabilities. They are terrific. I was hoping it might (someday) be possible to use command extensions (or other ways of manipulating environment variables) in saved BC sessions. As I noted, you already support environment variables. Command extensions (or perhaps a BC function?) to get parts of environment variables would be really handy as noted in my examples.

        Thanks again and kind regards,

        Rick

        Comment

        • Aaron
          Team Scooter
          • Oct 2007
          • 16017

          #5
          Ok, thanks for the feedback. I'll add these notes to our Customer Wishlist. If you have any questions about the command line and using parameters, please let us know.
          Aaron P Scooter Software

          Comment

          Working...