回传数据解析,兼容v5和v10
This commit is contained in:
35
tracking/utils/rename.py
Normal file
35
tracking/utils/rename.py
Normal file
@ -0,0 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Sat Jun 8 09:51:59 2024
|
||||
|
||||
@author: ym
|
||||
"""
|
||||
import os
|
||||
|
||||
def main():
|
||||
directory = r'D:\DetectTracking\runs\detect'
|
||||
directory = r'D:\DetectTracking\tracking\result\tracks'
|
||||
|
||||
suffix = '_'
|
||||
|
||||
for root, dirs, files in os.walk(directory):
|
||||
for name in dirs:
|
||||
old_name = os.path.join(root, name)
|
||||
new_name = os.path.join(root, f"{name}{suffix}")
|
||||
try:
|
||||
os.rename(old_name, new_name)
|
||||
except Exception as e:
|
||||
print(f"Failed to rename directory '{old_name}': {e}")
|
||||
|
||||
for name in files:
|
||||
old_name = os.path.join(root, name)
|
||||
file, ext = os.path.splitext(name)
|
||||
new_name = os.path.join(root, f"{file}{suffix}{ext}")
|
||||
try:
|
||||
os.rename(old_name, new_name)
|
||||
except Exception as e:
|
||||
print(f"Failed to rename file '{old_name}': {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user