TextEncoder

Batch Text Encoder

With the program version TextEncoder Pro CL it is possible to change the encoding and the used line break of text files via the command line. This makes it possible to control the TextEncoder via script. On this page we would like to introduce you to the topic and show you some examples of how to use the TextEncoder to edit and convert individual files or the contents of entire folders. In addition, at the bottom of this page, you’ll find an overview of all the parameters you can use.

Convert single or multiple Files

Let's start with a simple example. We would like to change the encoding of a single file to UTF-8. For this we pass the following parameters:

TextEncoder.exe -cl C:\test.txt enc=utf8

First you see the parameter -cl, which stands for command line. This parameter controls whether the TextEncoder is started with a graphical user interface or in command line mode without a graphical user interface. We always use this parameter if we want to control the TextEncoder via the command line. If we omit this parameter, the TextEncoder starts normally with a window. As the next parameter, we pass the path to the file we want to edit. Last we pass enc=utf8. This indicates that we want to convert to the UTF-8 encoding. At the bottom of this page you will find a list of all encodings that we can hand over here. This command converts the file C:\test.txt to UTF-8 format.

Similarly, we control the change of the line break type. The following example changes the linebreak of the file C:\test.txt to CR LF (Windows).

TextEncoder.exe -cl C:\test.txt lb=crlf

Next, we want to explicitly specify that the Byte Order Mark (bom) is written to the file. We do that with the parameter "bom":

TextEncoder.exe -cl C:\test.txt enc=utf8 bom=1

The parameter "bom" can take the values "keep", "0" or "1". With "1" the byte order mark is always written to the file, with "0" never. With "keep", the state of the original file is adopted (if possible). In other words, if the original file has a Byte Order Mark, then a Byte Order Mark is also written to the file. If not, not.

So far we have always overwritten the file C:\test.txt. Now we want to save the converted file as a new file. For this we use the parameter "save":

TextEncoder.exe -cl C:\test.txt enc=latin1 save=C:\new.txt

Here we change the encoding of the file C:\test.txt to Latin 1 (ISO 8859-1) and save the file as C:\new.txt. The file C:\test.txt remains unchanged.

TextEncoder.exe -cl C:\test1.txt C:\test2.txt enc=utf16le

Of course we can also edit several files at the same time. For example, in this example, we will convert the files C:\test1.txt and C:\test2.txt to the format UTF16-LE. You can specify as many files as you like.

Convert Contents of Folders

In addition to specifying individual files, you can also pass the path to a folder to edit its contents. The syntax is the same as editing files:

TextEncoder.exe -cl C:\folder enc=utf8

This command converts all files from the folder C:\folder to the UTF-8 format. If you do not want to overwrite the file, you can use one of the parameters save-folder, save-name or save-ext to change the folder, file name, or file extension of the edited files so that the edited files are saved as new files.

TextEncoder.exe -cl C:\folder enc=utf8 save-folder=C:\newfolder

In this example, we convert all files from the folder C:\folder to the UTF-8 format and save the result in the folder C:\newfolder. The original files remain unchanged.

TextEncoder.exe -cl C:\folder enc=utf8 save-folder=C:\new save-name=%%jjjj%%-%%mm%%-%%tt%

In this example we want to change not only the folder but also the name of the file. Here we save the files from the folder C:\folder in the format UTF-8 in the new folder C:\new and change the name of the file to the current date. This is what the placeholders used in the parameter "save-name" mean. Since we have not defined a new file extension with the parameter "save-ext", the file extension of the original file is adopted.

In case we do not want to convert all files from the folder, we can pass filters by using parameters. For example, to edit only files of a certain file extension:

TextEncoder.exe -cl C:\folder enc=utf8 filter-ext=txt

Here we pass the parameter "filter-ext" with the value "txt". This means that we only want to edit files with the extension TXT. If there are files with other endings in the same folder, they will be disregarded. Several file extensions can be specified as follows:

TextEncoder.exe -cl C:\folder enc=utf8 filter-ext=txt-htm

This filter ensures that only files with the extensions TXT or HTM are converted from the folder C:\folder. Additional filters and search options can be found at the bottom of this page in the list of all available parameters.

TextEncoder.exe -cl C:\folder enc=utf8 search-subdirs=0

In addition, you can use the parameter "search-subdirs" to specify whether only the files that are directly in the first level in the specified folder should be edited, or whether all subfolders of the specified folder should also be included. In this example, we specify search-subdirs=0. The result is that files that are in subfolders are not processed. If you omit this parameter or pass search-subdirs=1, all files from all subfolders are also processed. In the example, for example, also files from a folder like C:\folder\folder1\folder2.

Read Files using a specific Format

Normally the TextEncoder guesses the encoding and the line break of the existing files and reads the files on this basis. Of course, you can also enforce a specific encoding or line break type when reading the files. You do this with the parameters enc-read and lb-read.

TextEncoder.exe -cl C:\file.txt enc-read=utf8 lb-read=lf

Here we enforce that the file is read as UTF-8 format with the line break LF (Unix, Linux, macOS) and interpreted accordingly. If you omit one of the two parameters or both parameters, the value enc-read=auto respectively lb-read=auto is used. This means that the files are read and interpreted due to automatic recognition of the encoding and the line break.

Overview of all available Parameters

The following table lists all available parameters that you can use in the TextEncoder. Some of the parameters we have already presented in the examples on this page.

ParameterValuesDefaultDescription
[Files]any file path(s)
-Path to the file to be converted. You can specify multiple files in sequence to convert multiple files at the same time.
[Folders]any folder path(s)
-Path to a folder whose contents should be converted. To avoid converting all files from the folder, you can use the parameters search-subdirs, filter-ext, filter-name, filter-name-matchcase, filter-name-regex, filter-hiddenfiles and filter-onlytextfiles to narrow your search. Multiple folders can be specified consecutively to simultaneously convert the contents of multiple folders.
lbkeep, system, crlf, lf, cr, nl, ff, nel, ls, ps or vt
keepLinebreak type for the converted file. The value "keep" keeps the line break type of the original file, otherwise the specified type. The value "system" corresponds to the standard line break type of the operating system on which the TextEncoder is currently running. So for example crlf for Windows.  An overview of the different line break types can be found here.
lb-readauto, system, crlf, lf, cr, nl, ff, nel, ls, ps or vtautoLine break with which the file is read. If this parameter is not specified or "auto" is specified, an attempt is made to automatically detect the line break. The value "system" corresponds to the standard line break type of the operating system on which the TextEncoder is currently running. So for example crlf for Windows.
enckeep, ascii, latin1, latin2, win-ansi, win-1250, win-1251, win-1252, win-1253, utf7, utf8, utf16le, utf16be, utf32le or  utf32be
keepEncoding for the converted file. With "keep" the encoding of the original file is used, otherwise the specified encoding. The encoding "win-ansi" depends on the localization of your Windows version. The Windows code page that matches your language version of Windows will be used. An overview of all available encodings can be found here.
enc-readauto, ascii, latin1, latin2, win-ansi, win-1250, win-1251, win-1252, win-1253, utf7, utf8, utf16le, utf16be, utf32le or  utf32beautoEncoding with which the file is read. If this parameter is not specified, an attempt is made to automatically detect the coding. The encoding "win-ansi" depends on the localization of your Windows version. The Windows code page that matches your language version of Windows will be used.
bom0, 1 or keep
keepShould a byte order mark be written into the file? 0 for never, 1 for always, "keep" for as in the original file.
savePath of any file
-With this parameter you can save the converted file explicitly under a freely selectable file name. For example, you can specify save=C:\Folder\File.txt to save the converted file as C:\Folder\File.txt. If you only want to save the converted file in a different folder while keeping the file name and the file extension, please use the save-folder parameter and omit the save parameter. In addition, the parameters save-name for the name and save-ext for the file extension can be used in the same way and combined with each other. If you do not specify any of the save, save-folder, save-name, or save-ext parameters, the original file will be overwritten.
save-folderkeep or any text
keepFolder in which the converted file is saved. If you do not specify this parameter or if you call this parameter with the value "keep", the file is saved in the folder in which the original file is located. This parameter can be combined with the parameters save-name and save-ext. Each of these parameters is optional, allowing you to independently define the folder, name and extension. If you want to save the converted file under an explicit file name with path, name and extension, please use the parameter save. If you do not specify any of the save, save-folder, save-name, or save-ext parameters, the original file will be overwritten.
save-namekeep or any text
keepName without folder and file extension, with which the converted file is saved. If you do not specify this parameter or if you use this parameter with the value "keep", the file is given the same name as the original file. This parameter can be combined with the parameters save-folder and save-ext. Each of these parameters is optional, allowing you to independently define the folder, name and extension. If you want to save the converted file under an explicit file name with path, name and extension, please use the parameter save. If you do not specify any of the save, save-folder, save-name, or save-ext parameters, the original file will be overwritten.
save-extkeep or any text
keepFile extension with which the converted file is saved. If you do not specify this parameter or if you use this parameter with the value "keep", the converted file receives the file extension that also had the original file. This parameter can be combined with the parameters save-folder and save-name. Each of these parameters is optional, allowing you to independently define the folder, name and extension. If you want to save the converted file under an explicit file name with path, name and extension, please use the parameter save. If you do not specify any of the save, save-folder, save-name, or save-ext parameters, the original file will be overwritten.
search-subdirs0 or 11Should the subfolders be searched when editing a folder? 0 for no, 1 for yes. A value of 0 converts only the files that are in the first level of the folder.
filter-extany text
-If you only want to edit files with a specific extension, you can enter this extension(s) here. For example, filter-ext=txt to edit only files with the extension TXT. Multiple endings can be separated with a hyphen. For example, filter-ext=php-htm-html to edit only files with the extensions PHP, HTM or HTML. If you omit this parameter or leave it empty, files with all endings will be considered.
filter-nameany text
-If you only want to edit files with a specific name, you can enter a name here. All files containing the characters specified with "filter-name" are processed. With filter-name=ab, for example, files like abc.txt or xab.txt. If you omit this parameter or leave it empty, files with all names are taken into account.
filter-name-matchcase0 or 10Should the text specified with the parameter "filter-name" be interpreted according to its uppercase and lowercase writing? 0 for no, 1 for yes. If 1, the text in the file name must be the same in the same case. If 0 it is searched case-insensitive.
filter-name-regex0 or 10If the search filter specified with "filter-name" is to be interpreted as a regular expression, use 1. If you just want to search for the specified text, 0.
filter-hiddenfiles0 or 10Do you want to edit hidden files when converting a folder? 0 for no, 1 for yes. A value of 0 leaves all hidden files untouched, a value of 1 also handles the hidden files.
filter-onlytextfiles0 or 11Do you want to edit only text files when editing a folder? 0 for no, 1 for yes. If yes, each file is checked before being converted to see if it is a binary file and the processing is not carried out if so.
openfile0 or 10Should the converted file be opened after editing? openfile=1 will open the newly created file.
delfile0 or 10Should the original file be deleted after the conversion? delfile=1 deletes the original file. This option is only useful if the converted files are to be saved under a different name or in a different location than the original file and the original files should not be kept.

In principle, all these parameters can be combined with each other and used together. If you do not define a parameter, the specified default value is used for this parameter (the - indicates that this parameter is empty by default). In the column "Values" you can see all the values that this parameter can have.

Old Program Version

If you are still using the old version of the TextEncoders: An overview of the old TextEncoder batch version can be found here.