Move Files from different folder into one.

Hi,
New on matlab, i'm trying to find a way to move several files with the same 4 first letters from 4 different folder with the same first 4 letter into one.
My Files are name f100 .... and my folder Run... (with 4 random digits after "Run").
I've tried this code
movefile C:\Users\80CDGZ1\Documents\Data_EXCOG\EC01\Run1\Run*\f100* C:\Users\80CDGZ1\Documents\Data_EXCOG\EC01\Run1\Run1
But it's not working, does any of you have an idea ?
Thank's a lot
Theophane.

댓글 수: 5

Ruger28
Ruger28 2020년 2월 4일
What version of MATLAB are you running?
I'm running on R2016b
Ruger28
Ruger28 2020년 2월 4일
and what types of files?
i wish to move nifti files.
Ruger28
Ruger28 2020년 2월 4일
checkout rdir. it will loop recursively to find your files you wish to move. Then write some code to move the files.

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

답변 (2개)

Ruger28
Ruger28 2020년 2월 4일

0 개 추천

actually, I like this one better --> rdir
MainDirectory = 'C:\Users\80CDGZ1\Documents\Data_EXCOG\EC01\Run1'
EndDirectory = 'C:\Users\80CDGZ1\Documents\Data_EXCOG\EC01\Run1\Run1'
Files2Move = rdir(fullfile(MainDirectory,'**\*.nifti '));
for ii = 1:length(Files2Move)
currentfile = fullfile(Files2Move(ii).folder,Files2Move(ii).name);
movedfile = fullfile(EndDirectory,Files2Move(ii).name);
movefile(currentfile,movedfile); % move files
end

댓글 수: 1

The main problem for me is that i want to go in all my folder begginning by Run1 and ending by 4 digits. But if i'm asking matlab to go look for files in Run1* (* because the 4 last digit are random) he doesn't undestand it.

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

Image Analyst
Image Analyst 2020년 2월 4일

0 개 추천

Basically make up two filenames in the loop and call movefile
sourceFileName = fullfile(.......
destinationFileName = sprintf(.........
movefile(sourceFileName, destinationFileName);

댓글 수: 1

The main problem for me is that i want to go in all my folder begginning by Run1 and ending by 4 digits. But if i'm asking matlab to go look for files in Run1* (* because the 4 last digit are random) he doesn't undestand it.

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

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 2월 4일

댓글:

2020년 2월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by