David McCracken - 2019-02-22

This example is from https://stackoverflow.com/questions/2759067/rename-multiple-files-in-a-directory-in-python. The question is how to rename multiple files, for example to remove CHEESE_TYPE from CHEESE_CHEESE_TYPE.***making resulting filename CHEESE_TYPE. This is ambiguous, as there are two instances of this string in the name, and the result indicates that the extension has been removed. Most likely the goal is to remove the leading instance of the string and to preserve all extensions.
rene CHEESE_* *
does this, renaming, for example, CHEESE_CHEESE_TYPE.doc and CHEESE_CHEESE_TYPE.png to CHEESE_TYPE.doc and CHEESE_TYPE.png.
rene CHEESE_*.* */
would eliminate the extension, producing the result indicated in the question but only for the first file in a set with the same root but different extension. CHEESE_CHEESE_TYPE.doc would be renamed CHEESE_TYPE but rene's default collision avoidance would then cause CHEESE_CHEESE_TYPE.png to be renamed CHEESE_TYPE0. rene's -X option affords many alternative collision avoidance schemas.

 

Last edit: David McCracken 2019-02-22