I am working on a badly structured directory with *.nii files. First I use
dir = NotebookDirectory[] <> "ADNI";
fileNameList = FileNames["*.nii", dir, Infinity];
to get all the full paths, which works well.
The strange thing happens when I try to import them from the generated full paths and I am informed that some files can not be found.
So I make a test
Partition[Boole[FileExistsQ /@ fileNameList], 29] // ArrayPlot
and get (black for True, white for False)
Some examples from fileNameList are
{"F:\\Research\\Machine_Learning\\Alzheimer_Disease\\Dataset\\
ADNI1Screening_1.5T\\ADNI\\133_S_0912\\MPR__GradWarp__B1_Correction__
N3__Scaled_2\\2006-10-09_13_10_30.0\\S19884\\ADNI_133_S_0912_MR_MPR__
GradWarp__B1_Correction__N3__Scaled_2_Br_20081008094613870_S19884_
I119626.nii",
"F:\\Research\\Machine_Learning\\Alzheimer_Disease\\Dataset\\
ADNI1Screening_1.5T\\ADNI\\036_S_0759\\MPR__GradWarp__B1_Correction__
N3__Scaled\\2006-08-22_11_08_33.0\\S18094\\ADNI_036_S_0759_MR_MPR__
GradWarp__B1_Correction__N3__Scaled_Br_20070120004026768_S18094_
I36969.nii",
"F:\\Research\\Machine_Learning\\Alzheimer_Disease\\Dataset\\
ADNI1Screening_1.5T\\ADNI\\010_S_0422\\MPR____N3__Scaled\\2006-11-30_
14_02_07.0\\S23188\\ADNI_010_S_0422_MR_MPR____N3__Scaled_Br_
20070731162014912_S23188_I63332.nii",
"F:\\Research\\Machine_Learning
\\Alzheimer_Disease\\Dataset\\ADNI1Screening_1.5T\\ADNI\\012_S_1133\\
MPR____N3__Scaled\\2007-01-12_11_21_49.0\\S25016\\ADNI_012_S_1133_MR_
MPR____N3__Scaled_Br_20070711170922052_S25016_I59224.nii"}
and examples that tested by FileExistsQ for True and False, respectively, are
{"F:\\Research\\Machine_Learning\\Alzheimer_Disease\\Dataset\\
ADNI1Screening_1.5T\\ADNI\\002_S_0295\\MPR__GradWarp__B1_Correction__
N3__Scaled\\2006-04-18_08_20_30.0\\S13408\\ADNI_002_S_0295_MR_MPR__
GradWarp__B1_Correction__N3__Scaled_Br_20070319113623975_S13408_
I45108.nii",
"F:\\Research\\Machine_Learning\\Alzheimer_Disease\\Dataset\\
ADNI1Screening_1.5T\\ADNI\\002_S_0295\\MPR__GradWarp__B1_Correction__
N3__Scaled_2\\2006-04-18_08_20_30.0\\S13408\\ADNI_002_S_0295_MR_MPR__
GradWarp__B1_Correction__N3__Scaled_2_Br_20081001114556321_S13408_
I118671.nii"}

LongFileExistsQ[f_] := Quiet[ FileNames[f] === {f} ]– Rolf Mertig Apr 27 '20 at 14:53