.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()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句