You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# rename all the files in the folder# all the file will in outside0\*\analysis\*.mat# if file name contain "close"(case insensitive), rename it to "EyeClose.mat"# if file name contain "open"(case insensitive), rename it to "EyeOpen.mat"importosimportre# get all the file pathdefget_file_path(root_path):
file_path_list= []
forroot, dirs, filesinos.walk(root_path):
forfileinfiles:
file_path_list.append(os.path.join(root, file))
returnfile_path_list# rename the filedefrename_file(file_path_list):
forfile_pathinfile_path_list:
file_name=os.path.basename(file_path)
ifre.search(r'close', file_name, re.IGNORECASE):
new_file_name='EyeClose.mat'elifre.search(r'open', file_name, re.IGNORECASE):
new_file_name='EyeOpen.mat'else:
new_file_name=file_namenew_file_path=os.path.join(os.path.dirname(file_path), new_file_name)
os.rename(file_path, new_file_path)
if__name__=='__main__':
root_path=r'D:\\BCG\\outside0'file_path_list=get_file_path(root_path)
rename_file(file_path_list)
Autoreject:
In Progress
The text was updated successfully, but these errors were encountered:
In Progress
The text was updated successfully, but these errors were encountered: