How to utilize results of dir command.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Nicki
il 12 Nov 2013
Commentato: Image Analyst
il 12 Nov 2013
Hi, I am trying to use some code in a program of mine, that enables me to search for a file. In my treatment of data, I will always get only one result with the command:
dir * full *.xls (I have added some spaces on the sides of full, in order to keep things looking as they do in my command window.)
This command returns a string to me.
How do I save this string, or in any other way use this handle to open this exact file? I cannot store it to a variable using a command like:
Secretfilename=dir * full *.xls
In all this it is central that I do not know the entire name of the file I need. I only know that using this command will give said file as the only result.
Best regards, Nicki.
0 Commenti
Risposta accettata
Walter Roberson
il 12 Nov 2013
Use the function form of dir().
I am not sure what
* full *.xls
would be intended to mean. Possibly the equivalent would be
Secretfileinfo = dir('* full *.xls');
then possibly
fopen(Secretfileinfo.name, 'r')
It might be more complex if the "* full" is intended to designate a directory.
2 Commenti
Image Analyst
il 12 Nov 2013
Maybe you'd be interested in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Più risposte (1)
Vedere anche
Categorie
Scopri di più su File Operations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!