how to access a particular format files from a drive location?

hi.. In my D drive,many folders(app. 50 folders) are there.each having many formats of files.i need to access .zip files alone in each of the folders and move to separate folder..i am stuck here..

Antworten (2)

David Sanchez
David Sanchez am 28 Aug. 2013
The following will return a struct containing the .zip files in the folder specified by path_to_zip_files:
my_zips = dir('path_to_zip_files\*.zip')
Then,
for k=1:numel(my_zips)
my_zips(k).name
end
returns the names of the .zip files recursively. Adapt the code to your needs.

1 Kommentar

this code showing only .zip files in Desktop alone.but many .zip files are there in locations( \test),(\Users) ...i need to access all .zip files in C DRIVE fully,not in particular path,
my_zips = dir('C:\Users\test\Desktop\*.zip');
for k=1:numel(my_zips)
my_zips(k).name
end

Melden Sie sich an, um zu kommentieren.

David Sanchez
David Sanchez am 28 Aug. 2013
Bearbeitet: Walter Roberson am 4 Sep. 2013

0 Stimmen

8 Kommentare

the dir2 function provided there present a error, at least in my case. If you comment the " if ispc " condition, the recursive search works with no problem. With that part uncommented, an error message showed up regarding the mex file provided alongside the dir2.m file.
To find all your .zip files:
my_zips = dir2('your_folder','*.zip', '-r');
i think now you have all you needed
thanks...as i am using MATLAB 7.11.0(R2011b) version....dir2 function is not present in this version..any other alternate way to solve this??
You have to download DIR2 from the URL given in David's answer, and extract/save it somewhere in your path or in the same folder as the script that you are trying to build/run.
thanks....now its SHOWING ERROR like this..any thing need to do with the MEX file?
16 errors, 24 warnings
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Compile of 'dir2_mex.c' failed.
Which compiler are you using? What have you selected with
mex -setup
?
my compiler is Lcc-win32 C 2.4.1 (default)...which compiler is better for this?
Please show the complete log of the compilation.
sandy
sandy am 5 Sep. 2013
Bearbeitet: sandy am 18 Sep. 2013
>>
mex -setup
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler: [1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2010b\sys\lcc
[0] None
Compiler: 1
Please verify your choices:
Compiler: Lcc-win32 C 2.4.1 Location: C:\PROGRA~1\MATLAB\R2010b\sys\lcc
Are these correct [y]/n? y
Trying to update options file: C:\Users\test\AppData\Roaming\MathWorks\MATLAB\R2010b\mexopts.bat From template: C:\PROGRA~1\MATLAB\R2010b\bin\win32\mexopts\lccopts.bat
Done . . .
************************************************************************ Warning: The MATLAB C and Fortran API has changed to support MATLAB variables with more than 2^32-1 elements. In the near future you will be required to update your code to utilize the new API. You can find more information about this at: http://www.mathworks.com/support/solutions/en/data/1-5C27B9/?solution=1-5C27B9 Building with the -largeArrayDims option enables the new API. ************************************************************************

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Write C Functions Callable from MATLAB (MEX Files) finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 28 Aug. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by