Copying multiple files in a different location
60 次查看(过去 30 天)
显示 更早的评论
I have a bunch of files(around 1000) with the audio signals in them and I am trying to copy-paste them in another direction ( another folder). I would like to paste them with the same names but I do not want to use the dir function. Can anyone advise what other options do I have?
Many thanks in advance.
12 个评论
Walter Roberson
2020-10-7
编辑:Walter Roberson
2020-10-7
If they all start with a common prefix and have a common suffix then you can use copyfile with wildcards. For example,
copyfile('B*.wav', '../save_the_waves/')
Just make sure that the destination directory exists first.
回答(1 个)
Walter Roberson
2020-10-7
copy with the ls all the files and audio signals into another location
destination_directory = '../copy_of_files';
if ~exist(destination_directory, 'dir')
mkdir(destination_directory);
end
copyfile( '*.wav', destination_directory)
copyfile( '*.jpg', destination_directory);
5 个评论
Walter Roberson
2020-10-8
Example1 and example2 appear to be directories (also known as folders) rather than files ??
Are you sure you are not permitted to use dir() ? When you do not know the directory and file names ahead of time, dir() is the best way to proceed. There are cases where ls can output misleading filenames.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!