Numbering of Files
There are several types of numbering files and folders: On the one hand, you can intentionally decide to number a series of files - for example the tracks of an audio album or the episodes of a series. On the other hand, automatic numbering may be necessary if more than one file or folder would otherwise get the same name, which would not be possible, since file names must be unique.
In this tutorial we look at both of these types of numbering and look at the possibilities and settings that the FileRenamer offers us in this context.
- Numbering with the %num% Placeholder
- Other Placeholders for the Numbering
- Numbering of Same-Named Files
- Change existing Numbering of Files
Numbering with the %num% Placeholder
If you want to intentionally number a series of files or folders, you can do this with the placeholder %num%. The placeholder %num% can be used in every text field of the FileRenamer (for example in the functions "Search and Replace", "Mask", "Append Text" or "Insert Text") and stands for a number that depends on the position of the file in the list. You can change the positions of the files in the list by sorting the files with clicking on a column header or with moving the files manually in the list.
- Example 1: If you would like to make a file numbering, in which the number of the file is either prepended to the front of the existing file name or is attached to the back of the existing file name, you can use the function "Append" and simply write the text "%num%" in one of the two fields "Prepend this text to the front" or "Append this text at the back".
- Example 2: Of course, you can also combine the %num% placeholder with other characters, for example " (%num%)" to put the number of the file in brackets and to separate it with a space from the rest of the name. You could achieve the same result with the function "Mask" and the text "%name% (%num%)", with the placeholder %name% standing for the old file name in the mask.
In the menu of the FileRenamer under "Settings > Numbering" you can find some settings with which you can influence the %num% placeholder:
- Initial Value: By default, the initial value is "1". This means that the counting begins at 1 and the placeholder %num% is accordingly replaced by "1" for the first file in the file list. If you enter a different numerical value here, you can start the counting with any other number. For example with "0" (which makes the first file in the file list to have the number 0 and the second file in the file list becomes the 1) or with 10, 100 or an arbitrary other value. Even negative values are possible.
- Increment: Also the increment is "1" by default. This means that the counting is increased by 1 with each new file in the file list. When we start the counting with an initial value of 1 and we use an increment of 1, %num% will be "1" for the first file, "2" for the second file, "3" for the third file and so on. If we set the increase to "2" instead, the first 3 files in the list would be counted as 1, 4 and 7. Again we can also work with negative values. If we set the initial value, for example, to "10" and the increase to "-1", the placeholder %num% would be replaced by the values 10, 9 and 8 for the first 3 files in the file list.
- Fixed Length with Leading Zeros: With this option you can determine whether the numbers should be written without or with an arbitrary number of leading zeros. Especially with countings having a different number of characters (for example from one character of "1" up to 3 characters at "100"), it can look more beautiful if the numbers are written as "001", "002", ... "010" ... "100" in the file names instead of "1", "2", "10" and "100". If you enter "0" or "1" here, the numbers are written without leading zeros (1, 2, 3). With an indication of "3" you get the example above (001, 002, 003) or with "2" you get a series like "01", "02" and so on.
In the fields "Initial Value" as well as "Increment", not only integer values such as 1 or 2 can be used, but also decimal numbers or fractions such as 0.25 or 1/3. This makes it possible to give several files the same number. The internal incrementing of the numbers is done with decimal places, but when the numbers are set, the decimal places are cut off. As an example, with an initial value of 1.5 and an increment of 0.5, the file numbering would be 1 - 2 - 2 - 3 - 3 and so on, resulting from the internal count 1.5 - 2.0 - 2.5 - 3.0 - 3.5.
Using the following options, you can also reset or pause numbering increment based on specific criteria:
- Reset Numbering with every new Folder: If this option is activated, the counting is reset to the value from the field "initial value" with each file in the file list that is located in a different folder than the file before. Let us assume that we have an initial value of "1" and in our file list there are first 10 files from folder A and then 10 more files from folder B. If the option is activated, the first 10 files will receive the numbers 1 to 10. Since the eleventh file in the list is from a different folder than the tenth file in the list, the counting is reset at the eleventh file to the initial value "1" and the files 11 to 20 are again provided with the numbers 1 to 10. However, if this option is not activated, the folders do not play a role in the count. In this case, the same files would be numbered as 1 to 20.
- Do not increase at files with the same name in the file list one after the other: If this option is activated, the increment of the count is halted if two or more files are in the file list one after the other and only differ in their file extension. If we enable the option and we want our count to start from 1 and we have, for example, the files "a.png", "b.jpg", "b.png", "b.bmp", "c.jpg" and "c. png" in our file list in this order (all files are located in the same folder), we get the following result: the first file (a.png) gets the number 1, the next three files (b.jpg, b.png, b.bmp) all get the number 2 and the last two files (c.jpg, c.png) both get the number 3. If we hadn't activated the option, these files would be numbered from 1 to 6.
- Do not increase at files with the same name root in the file list one after the other: This option works similarly to the option explained previously. The difference is that this option only halts the count incrementing if consecutive files have the same root of the name. If we add the files "a.txt", "b.txt", "b_edit1.txt", "b_edit2.txt", "c.txt" as well as "c_edit.txt" to our file list in this order and our count should start at 1, we get the following result: the first file (a.txt) gets the number 1, the next three files (b.txt, b_edit1.txt, b_edit2.txt) with the word stem "b" get all the number 2 and the last two files (c.txt, c_edit.txt) stemming with "c" are both numbered with 3. This option does not include files with the same name, but only considers text appended to a filename. This option can thus be used independently of the previously mentioned option. If you want to add the same number to files with the same name as well as to files with the same root of the name, you can just activate both of the options.
Other Placeholders for the Numbering
In addition to the %num% placeholder, the FileRenamer provides you with the following other placeholders for the numbering of files and folders:
- %0num%, %00num%, %000num% and so on - Alternatively, you can control the number of leading zeros also without the setting "Fixed Length with Leading Zeros". While the placeholder %num% always adheres to this setting, the placeholders %0num%, %00num%, %000num% and so on are working independently of it. The placeholder %0num% corresponds to a setting of "2", the placeholder %00num% to a setting of "3" and so on. The other settings except the configuration of the leading zeros such as the settings for the initial value and the increment also apply to these placeholders in the same way like %num%.
- %abs0num% - If you do not want to care about the maximum number of characters of the number, you can alternatively use the placeholder %abs0num%. Also this placeholder works regardless of the setting "Fixed Length with Leading Zeros" and instead is based on the number of files in the list. Using the placeholder "%abs0num%", for 1 to 9 files in the file list, the number of the numbering is inserted without any leading zeros. From 10 files up to a maximum of 99 files in the file list, leading zeros are used to fill the number to a length of always 2 characters, from 100 files up to 999 it is always filled to 3 characters and so on.
- %abs% - In connection with the placeholders for the numbering, also the placeholder %abs% should not remain unmentioned, which stands for the absolute number of files in the list. As an example, you could use the function "Append > Prepend Text" with the text "%num% of %abs% ". If you have a total of 3 files in your file list, this would write "1 of 3 ", "2 of 3 " and "3 of 3 " in front of the 3 files. You could get the same result with using the mask "%num% of %abs% %name%", in which the placeholder %name% stands for the old name of the file.
In the overview over all placeholders of the FileRenamer, you can receive an overview of all other placeholders that you can use in the FileRenamer. In the section "Numbering" of this compilation, also the various %num% and %abs% placeholders are described.
Numbering of Same-Named Files
In addition to the intentional numbering by using the placeholder %num%, the FileRenamer can also lead to the situation that an automatic numbering of files or folders becomes necessary. Namely, if more than one files or folders would get the same name after applying the set changes and if those files or folders are additionally also stored in the same path. Since two files cannot have the same file path because file names have to be unique, the question arises in this case how the FileRenamer should deal with such a situation.
You can control this with the option "Number files for which the renaming would result in the same name", which you can find in the settings of the FileRenamer in the menu "Settings > Numbering > Same-Named Files".
- If this option is activated, files or folders of the same name after renaming are numbered, so that each file and folder gets a unique name again.
- If this option is not activated, files of potentially the same name lead to a warning message in the FileRenamer without renaming files. This gives you the chance to change your settings manually without the FileRenamer having done any automatic numbering.
Under this option, you will find a few more options with which you can control the numbering of the same named files, which of course are only used if the option "Number files for which the renaming would result in the same name" is activated:
- Mask: In the field "Mask", you can define a mask that serves as a pattern describing how the names of the files with a same name, which are numbered, should look like. The function is similar to the mask function from the main window of the FileRenamer. The mask must contain the placeholders %name% (name of the file after renaming) and %num% (number of numbering) and can contain any other characters that are allowed in file names. By default, "%name% (%num%)" is used as a mask. If, as an example, two files would get the same name "abc.txt" after applying all settings, the mask "%name% (%num%)" combined with the default settings (initial value of 1, increase of 1 and no leading zeros), would lead to the two file names "abc (1).txt" and "abc (2).txt" after renaming. If we work instead with an initial value of 0, an increase of 1 and 4 fixed zeros, the same case would lead to a renaming to the file names "abc (0000).txt" and "abc (0001).txt".
- Initial Value, Increment and Fixed Length with Leading Zeros: With these fields you can define the initial value of the counting (by default 1 for the first file), the increment of the counting with each new file (by default 1 per file) and the number of leading zeros used before the number. These options work the same way like the fields of the same name described in the section about the numbering with the placeholder %num%. Therefore, we do not want to go into this further at this point, but only refer to the section above.
Since the determination of the file name respectively the question of whether your current settings will lead to files of the same name depend on both all other files in the file list as well as on potential other files on your hard drive (for example because they are stored in the same directory as files from the file list, even if they have not been added to the file list), it can be a lot of work for the FileRenamer to create a preview for a file name.
For this reason, the FileRenamer offers you two options with which you can deactivate the preview regarding to two types of review:
- Activate Preview for Same-Named-Files-Renaming (slowly for a large number of files): This option only refers to files that are in the current file list. If this option is activated, all files of the file list are reviewed when creating the preview and checked whether two files would receive the same name. If so, the preview is adjusted according to the current mask for files of the same name. If you have a lot of files in your file list that you want to rename at the same time, the deactivation of this function can make the program faster. With a few files in the file list, it shouldn't be a problem if this option is activated and all files are checked when creating the preview.
- Check for Files stored on Hard Drive for the Preview (even slower): If this option is activated, not only the files from the file list within the program are taken into account, but also the other files that are stored in the same folders as the files from the file list. If you deactivate this option, hard disk access can be switched off while creating the preview.
However, the deactivation of one or both of these options can lead to the preview of a different number than the file will have later. This will always happen if a file of the same name is already existing on your hard disk or two or more files from your file list would lead to the same name with your settings.
The automatic numbering of same named files takes place regardless of the numbering with the placeholder %num%, which options were presented in the first section of this tutorial.
Change existing Numbering of Files
For changing an existing numbering of files, the FileRenamer offers you many options. It's easiest if you want to sequentially renumber a series of files that are already sequentially numbered. In this case, you can use the functions presented so far in this tutorial. First, you can configure your desired initial value as well as your desired increment value via the menu "Settings > Numbering", then you can use the placeholder %num% in any text field of the functions for changing the file name in the FileRenamer.
Modification of Consecutive Numberings
To change a consecutive existing numbering, for example, the replace function of the FileRenamer can be used. For example, you can search for the regular expression [0-9]+ and replace it with the placeholder %num% (the option "Interpret as Regular Expression" must be activated for this). With the regular expression [0-9]+ you can find all previous numbers in the file names (regardless of which numbers those are) and replace them with the new numbering using the placeholder %num% using all settings and options of this placeholder.
Increase or Decrease of existing Numberings
But what can we do if the numbering is not consecutive? Let's say we have the files "file000.txt", "file001.txt", "file004.txt" and "file007.txt". The numbering starts at "000" here, but we want the numbering to start at "001" instead, while keeping the "gaps" in the numbering. Accordingly, the files should be renamed to "file001.txt", "file002.txt", "file005.txt" and "file008.txt". We cannot work with the %num% placeholder at this point, since the numbering of the files does not follow any rule and we can therefore not define a uniform increment of the value. Instead, the numbering depends solely on the original number, which we want to increase by 1.
In this case, we can use the function "Number Adjustment", which you can find in the FileRenamer under "Changes > Name or Extension > Number Adjustment". With this function it is possible to increase or decrease existing numbers within file names by any value.
The function provides you with two options:
- Increment: With the first option "Increment" you can define the value to be added to the existing numbers. With positive values you can increase the existing numbers, with negative values you can decrease the existing numbers.
- Position: If your filename contains multiple numbers, the question arises which of these numbers should be increased or decreased. You can determine this with the option "Position". Positive numbers count the position from the front, negative numbers count the position from the back, and "0" adjusts all numbers within the filename regardless of their position.
- Leading Zeros: In this field you can specify how many leading zeros should be used for the numbers to be adjusted. This allows you, for example, to harmonize the number of zeros used if your numbers use a different number of zeros depending on the file name. This option can also be used to add leading zeros to numbers in filenames which originally have no leading zeros at all (more on that in the next section). If you write "0" in this field, the number of leading zeros is not changed and the pattern of the original number is used instead.
Let's look at an example for this. We have a file named "100-AB-30 (001).dat" and we want to add "1" only to the number "001" in it. Accordingly, we enter "1" as increment. If we would leave the position at "0", all numbers of the filename would be increased and we would get the result "101-AB-31 (002).dat". Since "001" is the third number within the filename, we could set the position to "3" and we would get our desired result "100-AB-30 (002).dat". However, if we want to rename other files like "100-33-30 (002).dat" or "200-AB-XY (003).dat" at the same time, counting the numbers from the beginning would not work and we would get "100-33-31 (002).dat" instead of "100-33-30 (003).dat". In this case, it would be better to define "-1" as the position so that the position is counted from the back. This would increase the number in brackets for all 3 files.
As you can see from this example, the function respects leading zeros. With an increase of 1, "001" becomes "002" and "009" becomes "010".
Add or reduce Leading Zeros of existing Numberings
Also if you want to change the number of leading zeros of existing numberings or other numbers in the file name, you can use the "number adjustment" function introduced in the last section.
Since we do not want to change the numerical value in this case, we set the increment to "0". On the other hand, in the field "Leading Zeros" we can define the number of zeros we want. The field "Position" can be used in the same way as described in the last section ("0" changes all numbers, "1" the first number from the front, "-2" the secound number from the end and so on).
- Example 1: We have 3 files named "1.txt", "10.txt" and "100.txt" and we want to rename these files to "001.txt" as well as "010.txt" while the file "100.txt" should keep its name. For this, we set the parameters of the number adjustment like the following: increment=0, position=0 and leading zeros=2. In the case of the position parameter, of course, also the values "1" (first number from the beginning) or "-1" (first number from the end) would also lead to the same result.
- Example 2: Our files are named "00001.txt", "00002.txt" and "00010.txt" and we want to reduce the number of leading zeros so that we get the filenames "01.txt", "02.txt" and "10.txt". For this, we use the following parameters: increment=0, position=0 and leading zeros=1.
The examples have demonstrated how the option can be used to both increase and decrease the number of leading zeros used in file names.