get file name from other directory
Show older comments
hello all :
folder = uigetdir
baseFileName1 = 'MTL.txt'
fullFileName =dir(fullfile(folder,['*', baseFileName1]))
fullFileName= fullfile(folder,fullFileName.name)
if exist(fullFileName)
this is my program i was using it under MAC OS , but now that i am using windows this program does not give me the real path of the file, and it shows the name of the file 2 times here is what i get
fullFileName =
2×1 struct array with fields:
name
folder
date
bytes
isdir
datenum
enmpty
fullFileName =
'C:\Users\itach\Desktop\Fmask_3_3 matlab\LC08_L1TP_196035_20181101_20181115_01_T2\._LC08_L1TP_196035_20181101_20181115_01_T2_MTL.txt\LC08_L1TP_196035_20181101_20181115_01_T2_MTL.txt'
as you see the first file is empty and the second one has the path wrong it shows a directory that does not exist
(._LC08_L1TP_196035_20181101_20181115_01_T2_MTL.txt)
can you help me to fix it and get the right directory and right name
2 Comments
Bob Thompson
on 12 Mar 2019
Why are you using 'fullfile' twice? Most likely this is why you are having your problem. I would make the following adjustment.
fullfile = dir([folder,'*',baseFileName1]);
Zakaria Sadok
on 12 Mar 2019
Accepted Answer
More Answers (0)
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!