Hi,
I am working on auto generation of reports and i am stuck right now. My aim is to check a network disk (let's say Z:\) once every day and if someone has put new folders (data) in that network drive then my script will analyse that new data.
The concept that i am unable to grasp right now is how to handle following 2 cases:
Z:\MainFolder\myDesiredFolder
and 2nd case
Z:\MinaFolder\SubFolder\Subfolder\Subfolder\myDesiredFolder
You are welcome with any kind of suggestions, tips or ideas.
Many thanks in advance.
\\Arsalan

 채택된 답변

Oleg Komarov
Oleg Komarov 2011년 3월 13일

1 개 추천

You can use recursive directory listing in the following way:
dirs = folderSizeTree('D:\');;
Then you can store results across days and use setdiff to find which new folder were added.
Oleg

댓글 수: 5

Muhammad Arsalan
Muhammad Arsalan 2011년 3월 14일
Thanks a lot for introducing me to recursive directory listing. Its works very well.
But in the next step i am having problems with setdiff.
I am doing following:
dirs1 = folderSizeTree('C:\Documents and Settings\');
here i get dirs1 struct1x1
then i add some folders at the location and again
folders1 = dirs1.name; % got 1x127 cell
dirs2 = folderSizeTree('C:\Documents and Settings\');
folders1 = dirs2.name; % got 9x129 cell
newfs = setdiff(folders1,folders2);
% got ===> Empty cell array: 0-by-1
% I have also tried to compare it after converting into char array
folders1 = char(folders1); % got long list of all folder paths and
folders2 = char(folders2); % compared 2 using different approaches
% haven't got what i am looking for. That is the new folder path.
Any hint??
Thanks in advance.
\\Arsalan
Oleg Komarov
Oleg Komarov 2011년 3월 14일
I guess folders1 = dirs2.name; should be folders2 = dirs2.name;
But the question is how do you get a 9 by 129?
I awalys get a vector cell array of strings.
Muhammad Arsalan
Muhammad Arsalan 2011년 3월 18일
Ya you are right. Sorry for my typing mistakes.
I need you help here.
I have
folders1 = dirs1.name; % got 1x127 cell
folders2 = dirs2.name; % got 1x129 cell
newfs = setdiff(folders1,folders2);
% got ===> Empty cell array: 0-by-1
So how can i look for new folders?
Thanks a lot.
Walter Roberson
Walter Roberson 2011년 3월 18일
Reverse the order of your arguments to setdiff:
newfs = setdiff(folders2,folders1);
Muhammad Arsalan
Muhammad Arsalan 2011년 3월 18일
Thanks Walter, now its working fine.

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by