def sanitize_filedot_ams_jpg(root_dir): pattern = re.compile(r'filedot\s ams\s jpg', re.IGNORECASE) for dirpath, dirnames, filenames in os.walk(root_dir): for filename in filenames: if pattern.search(filename): old_path = os.path.join(dirpath, filename) # Replace spaces with underscores, ensure .jpg extension new_name = re.sub(r'\s+', '_', filename) if not new_name.lower().endswith('.jpg'): new_name += '.jpg' new_path = os.path.join(dirpath, new_name) print(f"Renaming: old_path -> new_path") os.rename(old_path, new_path)
The "dot" in "Filedot" is the most crucial punctuation mark. In asset management, file extensions define behavior. If your AMS exports or references a file named Filedot AMS jpg (neglecting the proper dot), the system may read it as a file named Filedot AMS with an unknown extension jpg , or it may treat the entire string as a filename without an extension. Filedot AMS jpg
The tool runs the batch. A successful run outputs a log file ( Filedot_AMS_Log.txt ) showing which JPGs were moved and which failed (e.g., "Corrupt header: image_003.jpg"). def sanitize_filedot_ams_jpg(root_dir): pattern = re