Abacre Home > Advanced Find and Replace Home

Command line parameters

AFR allows working with command line parameters. It could be helpful if you use AFR inside of one automation process.

Format:

afr.exe -min -execute:find|replace|batch -searchfor "text to find" -replacewith "replacing text" -config file_name -mask masks -path "search path" -result file_name -format:xml|tab|comma|space|html -exit

All parameters in the format are optional. Use lower case only to for parameter' names and values except of file names. I.e. -min and -Min are different.

If you need more functionality for work with command line parameters, please, contact us: support@abacre.com

Example #1:

afr -execute:find -config c:\afr\mybatch.cfg -result c:\afr\results.csv -format:comma

This will start AFR and perform find operation with parameters from mybatch.cfg file and save result list of files into results.csv as comma separated file.

Example #2:

afr -execute:replace -searchfor "Hello World" -replacewith Hi -config c:\afr\mybatch.cfg -min -exit

This will start AFR in minimized (invisible mode), load parameters from c:\afr\mybatch.cfg. Then it will perform replace operation Hello World by Hi. After execution program will be closed automatically.

List of parameters:

-min

Program will start in minimized state.

Default: off.

-execute:find | replace | batch

Execute one of basis operations of AFR. Please, type operation type right after column (:) without any spaces. You can specify only one operation here.

Example: -execute:find

Default: if this option is not specified, when the program will start, it will not perform any operation.

-searchfor "text to find"

This field depends on operation defined by -execute parameter.

Note #1: if text after -searchfor parameter consists of several words, use double quotes. But if it's only one word, double quotes are not necessarily.

Note #2: it maybe nice to not use this parameter at all. Many people append searchfor/replace with parameters to config file with some automation tools. Or use batch file for the same purpose.

Examples:

-replacewith "replacing text"

This field depends on operation defined by -execute parameter.

Note #1: if text after -replacewith parameter consists of several words, use double quotes. But if it's only one word, double quotes are not necessarily.

Note #2: it maybe nice to not use this parameter at all. Many people append searchfor/replace with parameters to config file with some automation tools. Or use batch file for the same purpose.

Examples:

-config file_name

Specify name of the configuration file that will be loaded.

Example: -config "c:\Program Files\AFR\CppToPascal.cfg"

Note: 1. It should be the full path to the configuration file.

Note: 2. When file name is specified without path then the file is considered to be located in application data folder.

Note: 3. If the file name has spaces as in the example above, use double quotes.

Default: the program will load its settings from default configuration file as it is normally started without command line commands.

-mask masks

Specify mask as defined in Masks help topic. If -mask parameter has masks separated by comma then use double quotes.

Example: afr -mask "*.txt *.htm"

Default: empty (no value)

Note: If you use both: -config and -mask parameters then -mask parameter will override the settings of mask loaded from config file using -config parameter.

-path "search path"

Specify one or multiple search paths as defined in Search paths help topic.

Example: afr -path c:\docs

Default: empty (no value)

Note: If you use both: -config and -path parameters then -path parameter will override the settings of path loaded from config file using -config parameter.

-result file_name

Specify name of the file, where results of replacements will be stored.

Default: if you don't specify this parameter, AFR will not save search results.

Note: that directory, where you save the results, must already exist.

-format:tab | comma | space | html

Specify format of the file for results.

  • xml - xml file.
  • html - html file with results as a table.
  • tab - tab delimited file.
  • comma delimited file.
  • space - space delimited file.

    Default: tab

    -exit

    The program will terminate its work, when the execute command will be processed.

    Default: off.

    -batchfile filename

    Makes import of search for and replace with pairs from delimited text file into batch grid.

    For example: -batchfile c:\afr\import.csv -batchformat:comma

    -batchformat:xml | tab | comma | space | semicolon

    Specify format of the file for results.

  • xml - xml file.
  • html - html file with results as a table.
  • tab - tab delimited file.
  • comma delimited file.
  • space - space delimited file.
  • semicolon - semicolon delimited file.

    Default: tab

    Note: When file name is specified without path then the file is considered to be located in application's My Documents folder.

    Common questions:

    Q: Replace with parameter has quote ". What should I do?

    A: Use quote escaping: add second quote before each quote in source text. For example you want to use replace with:
    hello " world

    So in command line parameters it will be:
    afr afr -execute:replace -searchfor "test" -replacewith "hello "" world"