0
votes

I have a lot of folders each containing a lot of .txt files which i need to process with matlab.

i have a script finished which does it, it reads all .txt files in 1 folder and does some computing.

so if i want to process those files i move the script into the desired folder and run it, it is kinda lame to move the script every time.

is it possile to start a script in a standard directory, then make the script to ask me to browse for the desired directory to run the script in that directory? because it doesnt write any files, it just reads. after it finishes it should reset it, so i could browse to different folders every time. like save the path in a value and clear it at the end...

i use "fopen" in that script to open the .txt files, so it could be possible to assign the full path to that function, but its important to me to being able to browse the right folder every time i run the script.

1
Make it a function and pass it a directory name or use uigetdir to pick it. - excaza
You can call a file in a subfolder with fopen('folder/filename.txt'). List directories and files with dir, where you can use wildcards * to keep what you are interested in. - Laure
@Laure never explicitly provide a file separator, use fullfile or filesep to ensure proper file separators for the OS. - excaza

1 Answers

0
votes

i use

path=uigetdir;
fileid=fopen([path filesep 'file.txt']);

and it works just the way i wanted.

thanks @excaza and @Laure for a quick reply