How to automatically run a sequence of macros?

How to automatically run a sequence of macros?

12
Basic UserBasic User
12

    Dec 21, 2017#1

    Hello, long time UE user. A company I consult for is looking to do daily exports of inventory in CSV format which are FTP’d to a repository. The challenge is I have to run a sequence of regex queries on the CSV before it is ready to FTP. I already have the queries built and working. They are currently in macro format.

    What is the best way to automate:
    1.  Run the queries at a certain time of day without human intervention.
    2.  Auto upload the final csv to their repository.

    They would use their own licensed UE to do so, if this is possible.  

    Any help would be greatly appreciated.  

    6,680583
    Grand MasterGrand Master
    6,680583

      Dec 21, 2017#2

      Open help of UltraEdit, select tab Index, enter Command Line Parameters, double click on found index entry, double click on first item in opened window to open the help page Command Line Parameters. This help page explains two parameters you need for this task:
      1. /fni to force a new instance on running UltraEdit automated and which must be the first parameter on command line.
      2. /M,E="full path of macro file/macro name" to run a macro after starting UltraEdit automated and exit UE after finishing macro execution.
      It depends on your macro if more is needed than a command line like this:

      "%ProgramFiles%\IDM Computer Solutions\UltraEdit\uedit64.exe" /fni "Path to CSV file\File Name.csv" /M,E="Path to macro file\Macro File Name.mac/Macro Name"

      The macro could open itself the file "Path to CSV file\File Name.csv" in which case it would not be necessary to specify the file on command line.

      This command line can be executed as is as scheduled task with appropriate task options.

      A macro file can contain one or more macros. The optional /Macro Name part in command line can be omitted if the specified macro file contains only one macro.

      It looks like the macro to use for this task could contain something like:

      Code: Select all

      InsertMode
      ColumnModeOff
      Open "Path to CSV file\File Name.csv"
      IfNameIs "File Name"
      Top
      PerlReOn
      Find RegExp "Search Expression 1"
      Replace All "Replace Expression 1"
      Find RegExp "Search Expression 2"
      Replace All "Replace Expression 2"
      Find RegExp "Search Expression 3"
      Replace All "Replace Expression 3"
      SaveAs "FTP::AccountName\//server_directory|filename.csv"
      CloseFile NoSave
      EndIf
      
      So this macro opens a local file with specified file path, name and extension.

      Then it checks if the active file has really the expected file name, i.e. opening the file was successful. UltraEdit halts macro execution and shows an error message if the specified file could not be opened which needs to be confirmed by the user. So it is perhaps better to omit the command Open in macro and specify the file to open on command line because in this case no error message is displayed if the configuration setting Create new file if file specified on command line does not exist is enabled at Advanced - Settings or Configuration - Editor - New file creation. I would use in this case additionally the macro commands

      Code: Select all

      SelectAll
      IfSel
      Else
      ExitMacro
      EndIf
      
      This code to insert after the line IfNameIs "File Name" results in exiting the macro if the file with right file name is empty, i.e. it was created by UltraEdit as the file specified on command line does not exist. Please note that UltraEdit does not really create this file on hard disk as long as nothing is written into the file and saved.

      Next after opening the file with one of the two methods the regular expression replaces are executed on the file.

      Finally the SaveAs command is used to save the modified local file directly on server with uploading it via FTP. The specified account must be of course configured in FTP Account Manager of UltraEdit. And the specified directory on server must exist too.

      The local file as stored on hard disk is not modified by this macro, but that could be changed by inserting command Save above the line with command SaveAs.

      UltraEdit exits itself after macro execution because of option ,E on command line.

      On using this UltraEdit command line method as scheduled task care must be taken which account is configured for the scheduled task as the default location of INI file of UltraEdit with the FTP account data depends on used user account. It would be possible to specify on command line additionally the INI file to use containing the FTP account data using /i="Path to INI file\uedit64u.ini" to explicitly define the INI file to use. This can be also a separate INI file with a non standard INI file name to make sure that this INI file for automated CSV file creation and upload containing the FTP account data is never modified by a user of the machine using additionally UltraEdit.
      Best regards from an UC/UE/UES for Windows user from Austria

      12
      Basic UserBasic User
      12

        Dec 21, 2017#3

        Thank you so much Mofi. I have combined all the queries into one package as you show above. Will move on to the auto start of the scripts and see if I can get them to work too.  😀