필터 지우기
필터 지우기

Copy files, save the content, and change files name from code

조회 수: 2 (최근 30일)
Andre Tahmassian
Andre Tahmassian 2020년 9월 18일
댓글: Andre Tahmassian 2020년 9월 18일
I have about 10,000 dat files when I have thier names saved in a cell array, lets call this cell array A.
I also have another cell array with another group names which I call them cell array B in here.
I wish to copy those files into a different director when I have save the content of the files as they are, change their name with names from cell array B. For example:
Cell_Array_A = ['A1','A2', ....];
folder : ***/A/A1.dat , A2.dat, A3.dat , ...
NEW FOlder ***/B/B1.dat, B2.dat, B3.dat, ... when all I have from names are in cell array only. ( Cell_Array_B = ['B1','B2', ....];

답변 (2개)

Mohammad Sami
Mohammad Sami 2020년 9월 18일
From your question i assume the names in cell array are without the extensions.
ext = '.dat';
%Cell_Array_A
%Cell_Array_B
folderA = 'C:\somefolder\A';
folderB = 'C:\someotherfolder\B';
status = cellfun(@(a,b)copyfile(fullfile(folderA,[a ext]),fullfile(folderB,[b ext])),Cell_Array_A,Cell_Array_B);

Andre Tahmassian
Andre Tahmassian 2020년 9월 18일
Dear Mohammad,
By appreciating your kind help, I wish to let you know that I want to create actual files and this does not give me the option yet. I am not sure but I do not see any files to be created yet. I am relatively novice matlab coder so it looks different.
  댓글 수: 2
Mohammad Sami
Mohammad Sami 2020년 9월 18일
I thought you said you want to copy files ?
Andre Tahmassian
Andre Tahmassian 2020년 9월 18일
Indeed but creating identical files with different names following different cell array names

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by