Rename or Renumber Files renames or renumbers files on the hard drive.
This file-renaming utility adjusts text within image file names.
Be very careful with this module because its purpose is to rename (and overwrite) files! You will have the opportunity to confirm the name change for the first cycle only. If the folder containing the files contains subfolders, the subfolders and their contents will also be renamed. The module will not rename the file in test mode, so you should use test mode to ensure that the settings are correct.
You can use this module to standardize the number of characters in your file names and to remove unwanted characters from your file names. This is especially useful if you want file names that have numbers in them to appear in numerical order when processed by NamesAndTypes.
While this module performs basic renaming operations, if you can extract metadata from your images using the Metadata module, you may find using metadata substitution in SaveImages to be more flexible. Please refer to metadata handling for those modules and in Help for more details.
Examples
Renumbering can be useful when numbers within image filenames do not have a minimum number of digits and thus appear out of order when listed in some Unix/Mac OSX systems. For example, on some systems, files would appear like this and thus be measured differently from the expected sequence by CellProfiler:
1DrosophilaDAPI_1.tif
1DrosophilaDAPI_10.tif
1DrosophilaDAPI_2.tif
1DrosophilaDAPI_3.tif
1DrosophilaDAPI_4.tif
To renumber the files in the expected order, the numeric digits need to be padded with zeros to the same length. In this case, you would want to:
- Retain 16 characters at the beginning ("1DrosophilaDAPI_").
- Retain 4 characters at the end (".tif").
- "Renumber" as the handling method using 3 numerical digits.
- Set the text addition box to "No".
Original name | New name |
1DrosophilaDAPI_1.tif | 1DrosophilaDAPI_001.tif |
1DrosophilaDAPI_10.tif | 1DrosophilaDAPI_010.tif |
1DrosophilaDAPI_100.tif | 1DrosophilaDAPI_100.tif |
Renaming can be useful when file names are too long or have characters that interfere with other software or file systems. To accomplish the following, you would want to:
- Retain 5 characters at the beginning ("1Dros")
- Retain 8 characters at the end ("_<3-digit number>.tif", assuming they have already been renumbered)
- Select "Delete" as the handling method
- Check the text addition box and enter "DP" as text to place between the retained start and ending strings
Original name | New name |
1DrosophilaDAPI_001.tif | 1DrosDP_001.tif |
1DrosophilaDAPI_010.tif | 1DrosDP_010.tif |
1DrosophilaDAPI_100.tif | 1DrosDP_100.tif |
See also: NamesAndTypes, SaveImages
Settings:
Select the input image
Select the images associated with the files
you want to rename. This should be an image loaded by the
Input modules.
Be very careful because you will be renaming these files!
Number of characters to retain at start of file name
Number of characters at the start of the old
file name that will be copied over verbatim to the new file name. For
instance, if this setting is "6" and the file name is
"Image-734.tif", the output file name will also start with
"Image-".
Number of characters to retain at the end of file name
Number of characters at the end of the old
file name that will be copied over verbatim to the new file name. For
instance, if this setting is "4" and the file name is
"Image-734.tif", the output file name will also end with ".tif".
Handling of remaining characters
You can either treat the characters between the start and
end as numbers or you can delete them. If you treat them as numbers,
you will be given the opportunity to pad the numbers with zeros
so that all of your file names will have a uniform length. For
instance, if you were to renumber the highlighted portion of the
file "Image-734.tif" using four digits, the result would
be "Image-0734.tif".
Number of digits for numbers
(Used only if Renumber is selected)
Use this setting to pad numbers with zeros so that they
all have a uniform number of characters. For instance, padding
with four digits has the following result:
Original | Padded |
1 | 0001 |
10 | 0010 |
100 | 0100 |
1000 | 1000 |
Add text to the file name?
Select Yes if you want to add text
to the file name. If you had chosen Renumber above,
the module will add the text after your number.
If you had chosen Delete, the module will replace
the deleted text with the text you enter here.
Replacement text
(Used only if you chose to add text to the file name)
Enter the text that you want to add to each file name.
Replace spaces?
Select
Yes to replace spaces in the final
version of the file name with some other text.
Select No if the file name can have spaces
or if none of the file names have spaces.
Space replacement
This is the text that will be substituted for spaces
in your file name.