我遇到过很多需要特定文件复制和重命名任务的情况。所以我在 matlab 中编写了一个函数“easycopy”(和姊妹函数“easyrename”),以提供一种使用列表和通配符复制和重命名文件的便捷方式。
您可以在 Matlab File Exchange 上查看它们:
[ https://www.mathworks.com/matlabcentral/fileexchange/63417-easycopy][1]
[ https://www.mathworks.com/matlabcentral/fileexchange/63586-easyrename][1]
这是在这种情况下的样子:
这 ?带有“主题”的通配符匹配目录主题 1、2、3 和“文件夹?” 匹配文件夹 1、2、3、4。然后目标表达式使用 "...subject?\folder?new..." 创建文件夹 ...subject(1,2,3)\folder(1,2,3,4)new... 第一个资源 ”?” 匹配第一个“?” 在目标表达式中,第二个“?” 匹配第二个目标“?” 等等。“w*.txt”匹配所有“w”源文件,并将它们复制到“w*.txt”目标。
easycopy('c:\data\subject?\folder?\w*.txt','c:\data\subject?\folder?new\w*.txt')
COPYING FILES .....
Copying c:\data\subject1\folder1\wicked.txt
To c:\data\subject1\folder1new\wicked.txt
Copying c:\data\subject1\folder2\wicked.txt
To c:\data\subject1\folder2new\wicked.txt
Copying c:\data\subject1\folder3\wicked.txt
To c:\data\subject1\folder3new\wicked.txt
Copying c:\data\subject1\folder4\wicked.txt
To c:\data\subject1\folder4new\wicked.txt
Copying c:\data\subject2\folder1\wicked.txt
To c:\data\subject2\folder1new\wicked.txt
Copying c:\data\subject2\folder2\wicked.txt
To c:\data\subject2\folder2new\wicked.txt
Copying c:\data\subject2\folder3\wicked.txt
To c:\data\subject2\folder3new\wicked.txt
Copying c:\data\subject2\folder4\wicked.txt
To c:\data\subject2\folder4new\wicked.txt
Copying c:\data\subject3\folder1\wicked.txt
To c:\data\subject3\folder1new\wicked.txt
Copying c:\data\subject3\folder2\wicked.txt
To c:\data\subject3\folder2new\wicked.txt
Copying c:\data\subject3\folder3\wicked.txt
To c:\data\subject3\folder3new\wicked.txt
Copying c:\data\subject3\folder4\wicked.txt
To c:\data\subject3\folder4new\wicked.txt
DONE !