INNER CODE UNIT · Python
new_prefix
changyeyu/LLM-RL-Visualized · src/rename_images.py:102
new_prefix = str(new_names[n-1])
# Preserve the original file extension
ext = os.path.splitext(file)[1]
new_file = new_prefix + ext
old_path = os.path.join(root, file)
new_path = os.path.join(root, new_file)
try:
os.rename(old_path, new_path)
print(f"[{desc}] Renamed: {old_path} -> {new_path}")
except Exception as e:
print(f"Error renaming {old_path}: {e}")
else:
print(f"Number {n} exceeds the number of rows in the Excel file {excel_path} (file: {file}).")
else:
# If the file name does not match the pattern "幻灯片n", skip it
continue
def main():