Is there a way to prompt for multiple file select and assign those files (and paths) to a variable?

StackOverflow https://stackoverflow.com/questions/11748783

質問

Is there a way to prompt for multiple file select and assign those files (and paths) to a variable? For example, bring up a dialogue box that starts you in a base directory, and then allows you to assign files you select to different variables? Currently I have the paths and files hard coded in but this doesnt allow for any variety in the end. The other method i was using was using 24 instances of uigetfile, but this was tedious and time consuming so i swapped back to using hard coded file names.

役に立ちましたか?

解決

Reread the uitgetfile documentation, there is an option to allow multiselect files:

[FileName,PathName,FilterIndex] = uigetfile(...,'MultiSelect',selectmode) opens the dialog in multiselect mode. Valid values for selectmode are 'on' and 'off' (the default, which allows single selection only). If 'MultiSelect' is 'on' and you select more than one file in the dialog box, then FileName is a cell array of strings. Each array element contains the name of a selected file. Filenames in the cell array are sorted in the order your platform uses. Because multiple selections are always in the same folder, PathName is always a string identifying a single folder.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top