The simple script to collect file names and sizes fails on the 4th file with the following error:
"FileNotFoundError: [WinError 2] The system cannot find the file specified: 'A023_04.mp3'"
import ossiteID = 'A023' #This must match audio and NVSPL directories and filenamesdrive_audio = "E"dirName_audio = drive_audio +':\\data\\audio\\'+ siteID +'\\'fileNames_MP3 = [file for file in os.listdir(dirName_audio)] # this works:for val in fileNames_MP3: print(val)print('\n')# this works for the first three files:for val in fileNames_MP3: file_stats=os.stat(val) print(val, file_stats.st_size)
Here is the output:
A023_01.mp3A023_02.mp3A023_03.mp3A023_04.mp3A023_01.mp3 1073672486A023_02.mp3 1073644272A023_03.mp3 1073644273Traceback (most recent call last): File "E:\data\mp3_garage\funWithFileInfo.py", line 16, in <module> file_stats=os.stat(val)FileNotFoundError: [WinError 2] The system cannot find the file specified: 'A023_04.mp3'
I am able to view the properties using the Windows file manager, and don't see anything quirky about that particular file compared to the others.