Copy files from a folder to another directory

I have a set of 100 files in one folder named as: file_001.txt, file_002.txt ... file_100.txt.
I also have 100 folders named as: Folder_001, Folder_002 ... Folder_100.
I want to copy each file to the correspondent folder: file_001.txt to Folder_001, file_002.txt to Folder_002. Can anyone help me please?

回答 (1 件)

Sindar
Sindar 2020 年 10 月 13 日

0 投票

check out dir and copyfile. My suggestion would be to create the lists of file and folders first, check them, then do something like this:
for ind=1:1%length(filenames)
copyfile(filenames,foldernames)
end
(once the first file copies correctly, change the loop to go over all files

カテゴリ

ヘルプ センター および File ExchangeFile Operations についてさらに検索

タグ

質問済み:

2020 年 10 月 13 日

回答済み:

2020 年 10 月 13 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by