Grab a file without writting full name

조회 수: 4 (최근 30일)
Paulo Correia
Paulo Correia 2022년 10월 19일
댓글: Kevin Holly 2022년 10월 20일
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'];

답변 (1개)

Kevin Holly
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
Paulo Correia
Paulo Correia 2022년 10월 20일
Hello, how do I check if thie firmwareFiles is empty or has more than one file to throw an error?
Kevin Holly
Kevin Holly 2022년 10월 20일
To detect if it is empty:
isempty(firmwareFiles)
To detect how many files were detected:
size(firmwareFiles,1)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Package and Share Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by