UIGETFILE to filter out files starting with a specific character

7 次查看(过去 30 天)
I want to filter out file starting with a specific character. This code works on Matlab 2024b and older versions:
uigetfile('_*.dat')
…but in MATLAB R2025a, it gives a warning:
Warning: Invalid file filter _*.dat
And the fillter does not work.
How to apply this filter in Matlab 2025?
  3 个评论
dpb
dpb 2025-7-26
I did just reconfirm works as expected with earlier release on Win10, R2021b.
Submit this to Mathworks as an official support request/bug at <Product Support Page>
QUANG DAO
QUANG DAO 2025-7-31
Thank you so much for your suggestion.
I already submitted this bug to Mathworks.

请先登录,再进行评论。

回答(1 个)

Pramil
Pramil 2025-7-29
编辑:Pramil 2025-7-29
Hi QUANG,
I faced a similar issue in MATLAB R2025a and it appears to be a bug. The workaround for this if you want to continue using R2025a seems to be just typing in the file name or selecting the same from the available options once the modal for file selection opens.
>> [file, path] = uigetfile('_*.txt')
Warning: Invalid file filter _*.txt
file =
'_random.txt'
path =
'C:\Users\pkesarwa\Downloads\New folder\'
Hope this helps!
  2 个评论
QUANG DAO
QUANG DAO 2025-7-31
Thank you so much for your recommendation.
But my goal is to filter only files in the '_*.dat' format.
This makes it easier to select all files using Ctrl+A instead of clicking each one individually.
dpb
dpb 2025-7-31
编辑:dpb 2025-7-31
"my goal is to filter only files in the '_*.dat' format..."
I think the only programmatic workaround(*) until Mathworks issues an update or patch that addresses the specific issue (and I wouldn't be holding my breath waiting) is as suggested above to use a directory search output filtered by the wildcard pattern and then present those results to the user for selection.
(*) There is an alternate which would be to rename the files to replace the underscore with some other unique allowable character and then filter on that pattern. This is, of course, recognizably not an ideal solution to have to rename the files back to their original or just concede and use a different naming scheme; ergo, not a desireable option.
For Windows, the following would be allowable
Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:
  • The following reserved characters:
  • < (less than)
  • > (greater than)
  • : (colon)
  • " (double quote)
  • / (forward slash)
  • \ (backslash)
  • | (vertical bar or pipe)
  • ? (question mark)
  • * (asterisk)
  • Integer value zero, sometimes referred to as the ASCII NUL character.
  • Characters whose integer representations are in the range from 1 through 31, except for alternate data streams where these characters are allowed. For more information about file streams, see File Streams.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming Utilities 的更多信息

产品


版本

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by