Module Expr Str Import alias Import alias identifier Import alias identifier ImportFrom alias alias Assign NameStore Str Assign NameStore Str ClassDef bases AttributeLoad NameLoad attr body Assign NameStore Str Assign NameStore Str Assign NameStore Num FunctionDef arguments args NameParam defaults body Expr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr keyword Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Num keyword Num keyword Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Num keyword Num keyword Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str ListLoad NameLoad NameLoad keyword Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Num keyword Num keyword BinOpMod Str Call NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str NameLoad keyword BinOpMod Str Call NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Str keyword Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str NameLoad keyword BinOpMod Str Call NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Str keyword Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return ListLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr If CompareEq AttributeLoad NameLoad attr NameLoad body AugAssignAdd NameStore ListLoad AttributeLoad NameLoad attr AugAssignAdd NameStore ListLoad AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body AugAssignAdd NameStore ListLoad AttributeLoad NameLoad attr AugAssignAdd NameStore ListLoad AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body AugAssignAdd NameStore ListLoad AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Assign NameStore SubscriptLoad NameLoad Slice AttributeLoad AttributeLoad NameLoad attr attr If CompareEq AttributeLoad AttributeLoad NameLoad attr attr Num body Assign NameStore Str Assign NameStore SubscriptLoad NameLoad Slice AttributeLoad AttributeLoad NameLoad attr attr orelse Assign NameStore SubscriptLoad NameLoad Slice UnaryOpUSub AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore SubscriptLoad NameLoad Slice AttributeLoad AttributeLoad NameLoad attr attr UnaryOpUSub AttributeLoad AttributeLoad NameLoad attr attr If CompareEq AttributeLoad NameLoad attr NameLoad body If UnaryOpNot Call AttributeLoad NameLoad attr body Raise Call NameLoad BinOpMod Str TupleLoad NameLoad NameLoad Assign NameStore BinOpAdd BinOpAdd Str Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr Str Assign NameStore BinOpMod NameLoad Call NameLoad NameLoad orelse If CompareEq AttributeLoad NameLoad attr NameLoad body Assign NameStore Str orelse Raise Call NameLoad BinOpMod Str AttributeLoad AttributeLoad NameLoad attr attr If AttributeLoad NameLoad attr body AugAssignAdd NameStore AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore BinOpAdd BinOpAdd NameLoad NameLoad NameLoad If AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr Str AttributeLoad AttributeLoad NameLoad attr attr If AttributeLoad NameLoad attr body Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad If AttributeLoad AttributeLoad NameLoad attr attr body Return ImportFrom alias Expr Call NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr TupleLoad Num Num If AttributeLoad AttributeLoad NameLoad attr attr body Expr Call AttributeLoad NameLoad attr Num Num ListLoad ListLoad Str orelse Assign NameStore ListLoad TupleLoad AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad NameLoad attr Num Num NameLoad keyword TupleLoad Str Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If AttributeLoad NameLoad attr body Raise Call AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str If BoolOpAnd NameLoad CompareEq NameLoad Num body Assign TupleStore NameStore NameStore NameStore NameStore NameStore NameLoad Assign NameStore CompareNotEq Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore IfExp NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr If CompareEq Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr body Assign NameStore Num Assign NameStore NameLoad orelse Assign NameStore NameLoad Assign NameStore ListLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Num Assign NameStore NameLoad If BoolOpAnd UnaryOpNot NameLoad CompareEq NameLoad Num body Assign NameStore BinOpAdd NameLoad ListLoad AttributeLoad NameLoad attr Str Assign NameStore Num Return TupleLoad NameLoad NameLoad NameLoad decorator_list decorator_list
N/A N/A <b>Rename or Renumber Files</b> renames or renumbers files on the hard drive.
<hr>
This file-renaming utility adjusts text within image file names.
<i><b>Be very careful with this module because its purpose is
to rename (and overwrite) files!</b></i>  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 <b>NamesAndTypes</b>.<br>

While this module performs basic renaming operations, if you can extract
metadata from your images using the <b>Metadata</b> module, you may find using
metadata substitution in <b>SaveImages</b> to be more flexible. Please
refer to metadata handling for those modules and in Help for more details.

<h3>Examples</h3>

<p>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:</p>
1DrosophilaDAPI_1.tif<br>
1DrosophilaDAPI_10.tif<br>
1DrosophilaDAPI_2.tif<br>
1DrosophilaDAPI_3.tif<br>
1DrosophilaDAPI_4.tif<br>
<p>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:
<ul>
<li>Retain 16 characters at the beginning ("1DrosophilaDAPI_").</li>
<li>Retain 4 characters at the end (".tif").</li>
<li>"Renumber" as the handling method using 3 numerical digits.</li>
<li>Set the text addition box to "No".</li>
</ul>

<table border = "1">
<tr><td><i>Original name</i></td><td><i>New name</i></td></tr>
<tr><td>1DrosophilaDAPI_1.tif</td>  <td>1DrosophilaDAPI_001.tif</td></tr>
<tr><td>1DrosophilaDAPI_10.tif</td> <td>1DrosophilaDAPI_010.tif</td></tr>
<tr><td>1DrosophilaDAPI_100.tif</td><td>1DrosophilaDAPI_100.tif</td></tr>
</table>

<p>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:
<ul>
<li>Retain 5 characters at the beginning ("1Dros")</li>
<li>Retain 8 characters at the end ("_<3-digit number>.tif", assuming they have already been renumbered)</li>
<li>Select "Delete" as the handling method</li>
<li>Check the text addition box and enter "DP" as text to place between the retained start and ending strings</li>
</ul>
<table border = "1">
<tr><td><i>Original name</i></td><td><i>New name</i></td></tr>
<tr><td>1DrosophilaDAPI_001.tif</td> <td>1DrosDP_001.tif</td></tr>
<tr><td>1DrosophilaDAPI_010.tif</td> <td>1DrosDP_010.tif</td></tr>
<tr><td>1DrosophilaDAPI_100.tif</td> <td>1DrosDP_100.tif</td></tr>
</table>

See also: <b>NamesAndTypes</b>, <b>SaveImages</b>
 N/A os N/A cellprofiler.cpmodule cpm N/A cellprofiler.settings cps cellprofiler.settings YES NO N/A A_RENUMBER Renumber N/A A_DELETE Delete RenameOrRenumberFiles N/A N/A cpm CPModule N/A N/A module_name RenameOrRenumberFiles N/A category File Processing N/A variable_revision_number 2 create_settings N/A N/A self N/A N/A N/A Create the settings for the module's UI N/A N/A self warning N/A N/A cps Divider This module allows you to rename (overwrite) your files. Please see the help for this module for warnings. N/A N/A self image_name N/A N/A cps FileImageNameSubscriber Select the input image N/A cps NONE doc 
            Select the images associated with the files
            you want to rename. This should be an image loaded by the
            <b>Input</b> modules.
            Be very careful because you will be renaming these files! N/A N/A self number_characters_prefix N/A N/A cps Integer Number of characters to retain at start of file name 6 minval 0 doc 
            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-". N/A N/A self number_characters_suffix N/A N/A cps Integer Number of characters to retain at the end of file name 4 minval 0 doc 
            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". N/A N/A self action N/A N/A cps Choice Handling of remaining characters N/A A_RENUMBER A_DELETE doc 
            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-<u>734</u>.tif" using four digits, the result would
            be "Image-0734.tif". N/A N/A self number_digits N/A N/A cps Integer Number of digits for numbers 4 minval 0 doc N/A 
            <i>(Used only if %(A_RENUMBER)s is selected)</i><br>
            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:<br>
            <code><table>
            <tr><th>Original</th><th>Padded</th></tr>
            <tr><td>1</td><td>0001</td></tr>
            <tr><td>10</td><td>0010</td></tr>
            <tr><td>100</td><td>0100</td></tr>
            <tr><td>1000</td><td>1000</td></tr>
            </table></code> N/A globals N/A N/A self wants_text N/A N/A cps Binary Add text to the file name? False doc N/A 
            Select <i>%(YES)s</i> if you want to add text
            to the file name. If you had chosen <i>%(A_RENUMBER)s</i> above,
            the module will add the text after your number.
            If you had chosen <i>%(A_DELETE)s</i>, the module will replace
            the deleted text with the text you enter here. N/A globals N/A N/A self text_to_add N/A N/A cps Text Replacement text doc 
            <i>(Used only if you chose to add text to the file name)</i><br>
            Enter the text that you want to add to each file name. N/A N/A self wants_to_replace_spaces N/A N/A cps Binary Replace spaces? False doc N/A 
            Select <i>%(YES)s</i> to replace spaces in the final
            version of the file name with some other text.
            <p>Select <i>%(NO)s</i> if the file name can have spaces
            or if none of the file names have spaces.</p> N/A globals N/A N/A self space_replacement N/A N/A cps Text Space replacement _ doc 
            This is the text that will be substituted for spaces
            in your file name. N/A settings N/A N/A self N/A N/A N/A Return settings in the order that they should appear in pipeline N/A N/A N/A self image_name N/A self number_characters_prefix N/A self number_characters_suffix N/A self action N/A self number_digits N/A self wants_text N/A self text_to_add N/A self wants_to_replace_spaces N/A self space_replacement N/A visible_settings N/A N/A self N/A N/A N/A Return the settings to display in the GUI N/A result N/A N/A self warning N/A self image_name N/A self number_characters_prefix N/A self number_characters_suffix N/A self action N/A N/A N/A self action A_RENUMBER N/A N/A result N/A N/A self number_digits N/A result N/A N/A self wants_text N/A N/A self wants_text N/A N/A result N/A N/A self text_to_add N/A result N/A N/A self wants_to_replace_spaces N/A N/A self wants_to_replace_spaces N/A N/A result N/A N/A self space_replacement N/A result N/A run N/A N/A self workspace N/A N/A N/A Run on an image set N/A image_name N/A N/A self image_name value N/A m N/A workspace measurements N/A path N/A N/A m get_current_image_measurement N/A PathName_%s image_name N/A file_name N/A N/A m get_current_image_measurement N/A FileName_%s image_name N/A prefix N/A file_name N/A N/A N/A self number_characters_prefix value N/A N/A N/A N/A self number_characters_suffix value 0 N/A N/A suffix N/A middle N/A file_name N/A N/A N/A self number_characters_prefix value N/A N/A suffix N/A file_name N/A N/A N/A N/A self number_characters_suffix value N/A middle N/A file_name N/A N/A N/A self number_characters_prefix value N/A N/A N/A self number_characters_suffix value N/A N/A N/A self action A_RENUMBER N/A N/A N/A N/A N/A middle isdigit N/A N/A N/A ValueError N/A The middle of the filename, "%s", is "%s".
It has non-numeric characters and can't be converted to a number N/A file_name middle N/A format N/A N/A %0 N/A str N/A N/A self number_digits value d N/A middle N/A format N/A int middle N/A N/A N/A N/A self action A_DELETE N/A N/A middle N/A N/A N/A NotImplementedError N/A Unknown action: %s N/A N/A self action value N/A N/A self wants_text N/A N/A middle N/A N/A self text_to_add value N/A new_file_name N/A N/A prefix middle suffix N/A N/A self wants_to_replace_spaces N/A N/A new_file_name N/A N/A new_file_name replace N/A N/A self space_replacement value N/A N/A self show_window N/A N/A N/A N/A workspace display_data old_file_name file_name N/A N/A N/A workspace display_data new_file_name new_file_name N/A N/A N/A workspace pipeline test_mode N/A N/A bioformats.formatreader clear_image_reader_cache N/A N/A clear_image_reader_cache N/A N/A N/A os rename N/A N/A N/A os path join path file_name N/A N/A N/A os path join path new_file_name N/A display N/A N/A self workspace figure N/A N/A N/A Display the pathname conversion N/A N/A N/A figure set_subplots N/A 1 1 N/A N/A N/A workspace pipeline test_mode N/A N/A N/A N/A figure subplot_table 0 0 N/A N/A Files not renamed in test mode N/A N/A statistics N/A N/A N/A N/A workspace display_data old_file_name N/A N/A workspace display_data new_file_name N/A N/A N/A figure subplot_table 0 0 statistics col_labels N/A Old file name New file name N/A validate_module_warnings N/A N/A self pipeline N/A N/A N/A Warn user re: Test mode  N/A N/A pipeline test_mode N/A N/A N/A N/A cps ValidationError RenameOrRenumberFiles will not rename files in test mode N/A self image_name N/A upgrade_settings N/A N/A self setting_values variable_revision_number module_name from_matlab N/A N/A N/A Upgrade settings from previous pipeline versions

        setting_values - string values for each of the settings
        variable_revision_number - the revision number of the module at the
                                   time of saving
        module_name - the name of the module that saved the settings
        from_matlab - true if pipeline was saved by CP 1.0
         N/A N/A from_matlab N/A variable_revision_number 1 N/A N/A N/A image_name number_characters_prefix number_characters_suffix text_to_add number_digits setting_values N/A wants_text N/A N/A N/A text_to_add lower N/A N/A N/A cps DO_NOT_USE lower N/A wants_text N/A wants_text N/A cps YES N/A cps NO N/A N/A N/A N/A number_digits lower N/A N/A N/A cps DO_NOT_USE lower N/A N/A number_digits 4 N/A action A_DELETE N/A N/A action A_RENUMBER N/A setting_values N/A image_name number_characters_prefix number_characters_suffix action number_digits wants_text text_to_add N/A variable_revision_number 1 N/A from_matlab False N/A N/A N/A from_matlab N/A variable_revision_number 1 N/A N/A setting_values N/A setting_values N/A N/A cps NO _ N/A variable_revision_number 2 N/A N/A setting_values variable_revision_number from_matlab N/A N/A