get file name from other directory
Mostrar comentarios más antiguos
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 comentarios
Bob Thompson
el 12 de Mzo. de 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
el 12 de Mzo. de 2019
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre File Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!