答案 0 :(得分:0)
.mat
文件是包含Matlab可以读取的数据的文件。如果.dat
文件的格式也可以由Matlab读取,那么您的问题就是一个简单的文件重命名问题。更准确地说,将文件夹中所有文件的扩展名从dat
更改为mat
。
代码将如下所示:
# Python3 code to rename multiple
# files in a directory or folder
# importing os module
import os
# Function to rename multiple files
def main():
i = 0
for filename in os.listdir("xyz"): #xyz=the folder which has your files
dst ="s0" + str(i) + "lre.mat" #I suppose the numbering of the files begins with 0. This is the name pattern I detected from your screenshot
src ='xyz'+ filename
dst ='xyz'+ dst
# rename() function will
# rename all the files
os.rename(src, dst)
i += 1
# Driver Code
if __name__ == '__main__':
# Calling main() function
main()