Move File to a different folder

Good day guys,
Please I need a help.
I have a lot file containing temperature profile data. Some of these file contain a lot of irregular data like too high or too low values. But these files I dont know them by their filenames.
I want MATLAB to help me look for the files that contain this irregular values and move these files to a different folder. Please how can i achieve this?

7 件のコメント

Rik
Rik 2019 年 9 月 7 日
You can do this by solving it one problem at a time. First get a list of files so you can loop through them, then determine if a file contains irregular values, then move those files.
If you don't post anything specific about your files we can't help you any further.
TTA
TTA 2019 年 9 月 7 日
Thanks so much for enlightment.
Please how can I identify a file with irregular set of values.
TTA
TTA 2019 年 9 月 7 日
can I send you a list of files?
dpb
dpb 2019 年 9 月 7 日
"how can I identify a file with irregular set of values."
First by defining what "irregular" means, specifically, down to an algorithm that can be coded.
Then, loop thru the exhaustive list of all candidate files, read each one in turn and analyze it for "good:bad" and do the appropriate thing with each.
There's absolutely no way to know from the outside looking in unless there is some other piece of information that can be linked to file name, time or other file ID.
TTA
TTA 2019 年 9 月 7 日
編集済み: TTA 2019 年 9 月 7 日
yeah..I got the point like but implementing is a bit tricky for me. like i dentify a file with zeros for example
Rik
Rik 2019 年 9 月 7 日
The mind reading toolbox isn't released yet, so you will have to provide us with details and/or example files. Otherwise we will not be able to meaningfully help you. We have given you an outline for the solution. Now it's your turn.
TTA
TTA 2019 年 9 月 7 日
Hi Rik,
Attached are the files for example. I want to separate this file that the Temperateure (Temp) falls within 150-350K.
Thanks

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2019 年 9 月 7 日

1 投票

projectdir = 'files';
dir_for_irregular = fullfile(projectdir, 'irregular');
if ~exist(dir_for_irregular, 'dir')
mkdir(dir_for_irregular);
end
dinfo = dir( fullfile(projectdir, '*_nc')); %eg atmPrf_C004.2010.093.12.28.G28_2013.3520_nc
filenames = fullfile( projectdir, {dinfo.name} );
nfiles = length(filenames);
for K = 1 : nfiles
thisfile = filenames{K};
temperature = ncread(thisfile, 'Temp') + 273.15; %because they are in C
if any(temperature(:) < 150) | any(temperature(:) > 350)
%this file is irregular
movefile(thisfile, dir_for_irregular);
end
end

1 件のコメント

TTA
TTA 2019 年 9 月 7 日
OMG............Robertson thanks so much. You just made my day.
I love MATLAB

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

タグ

質問済み:

TTA
2019 年 9 月 7 日

コメント済み:

TTA
2019 年 9 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by