Grab a file without writting full name
4 次查看(过去 30 天)
显示 更早的评论
I want to grab a file that is always located in same folder that starts with the name "Target" and ends with ".hex" but in front of Target there is a version number that can change.
In the following line you can see I'm trying to use the " * " to pick up any file. But this doesn't work. Anyone can help me how to do this?
firmwareFile = [basePath{1} '..\binaries\Target*.hex'];
0 个评论
回答(1 个)
Kevin Holly
2022-10-19
编辑:Kevin Holly
2022-10-19
Can you try this?
folder = [basePath{1},filesep,'binaries']; % I'm assuming this is the folder location
firmwareFiles = dir(fullfile(folder,'Target*.hex'))
11 个评论
Kevin Holly
2022-10-20
To detect if it is empty:
isempty(firmwareFiles)
To detect how many files were detected:
size(firmwareFiles,1)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Package and Share Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!