0

A folder that is shared in the local network, is mapped to a network drive in Windows 10 (letter V:). The following python lines check if the file exists in the mapped network drive:

import os
print(os.path.isfile("V:\\FORENSOR DTB Dataset processed\\pow_day_125236_07.5.avi"))

this returns false. Same thing happens for any file in the folder. copyfile() from shutils also throws the error that file does not exist. However the file is in the folder. What is the issue here?

After the suggested/linked answers, I have tried all the following (V: is the drive letter and DARAS-NAS the name of the network location):

print(os.path.isfile(r'\\DARAS-NAS\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi'))
print(os.path.isfile(r'\\DARAS-NAS\\FORENSOR DTB Dataset processed\\pow_day_125236_07.5.avi'))
print(os.path.isfile(r'\\\\DARAS-NAS\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi'))
print(os.path.isfile(r'\\\\DARAS-NAS\\FORENSOR DTB Dataset processed\\pow_day_125236_07.5.avi'))
print(os.path.isfile(r'\DARAS-NAS\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi'))
print(os.path.isfile(r'/DARAS-NAS/FORENSOR DTB Dataset processed/pow_day_125236_07.5.avi'))
print(os.path.isfile(r'//DARAS-NAS/FORENSOR DTB Dataset processed/pow_day_125236_07.5.avi'))

print(os.path.isfile(r"\\DARAS-NAS\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi"))
print(os.path.isfile(r"\\DARAS-NAS\\FORENSOR DTB Dataset processed\\pow_day_125236_07.5.avi"))
print(os.path.isfile(r"\\\\DARAS-NAS\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi"))
print(os.path.isfile(r"\\\\DARAS-NAS\\FORENSOR DTB Dataset processed\\pow_day_125236_07.5.avi"))
print(os.path.isfile(r"\DARAS-NAS\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi"))
print(os.path.isfile(r"/DARAS-NAS/FORENSOR DTB Dataset processed/pow_day_125236_07.5.avi"))
print(os.path.isfile(r"//DARAS-NAS/FORENSOR DTB Dataset processed/pow_day_125236_07.5.avi"))

print(os.path.isfile('\\DARAS-NAS\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi'))
print(os.path.isfile('\\DARAS-NAS\\FORENSOR DTB Dataset processed\\pow_day_125236_07.5.avi'))
print(os.path.isfile('\\\\DARAS-NAS\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi'))
print(os.path.isfile('\\\\DARAS-NAS\\FORENSOR DTB Dataset processed\\pow_day_125236_07.5.avi'))
print(os.path.isfile('\DARAS-NAS\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi'))
print(os.path.isfile('/DARAS-NAS/FORENSOR DTB Dataset processed/pow_day_125236_07.5.avi'))
print(os.path.isfile('//DARAS-NAS/FORENSOR DTB Dataset processed/pow_day_125236_07.5.avi'))

print(os.path.isfile("\\DARAS-NAS\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi"))
print(os.path.isfile("\\DARAS-NAS\\FORENSOR DTB Dataset processed\\pow_day_125236_07.5.avi"))
print(os.path.isfile("\\\\DARAS-NAS\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi"))
print(os.path.isfile("\\\\DARAS-NAS\\FORENSOR DTB Dataset processed\\pow_day_125236_07.5.avi"))
print(os.path.isfile("\DARAS-NAS\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi"))
print(os.path.isfile("/DARAS-NAS/FORENSOR DTB Dataset processed/pow_day_125236_07.5.avi"))
print(os.path.isfile("//DARAS-NAS/FORENSOR DTB Dataset processed/pow_day_125236_07.5.avi"))

##############

print(os.path.isfile(r'V:\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi'))
print(os.path.isfile(r'V:\\FORENSOR DTB Dataset processed\\pow_day_125236_07.5.avi'))
print(os.path.isfile(r'V:/FORENSOR DTB Dataset processed/pow_day_125236_07.5.avi'))

print(os.path.isfile(r"V:\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi"))
print(os.path.isfile(r"V:\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi"))
print(os.path.isfile(r"V:/FORENSOR DTB Dataset processed/pow_day_125236_07.5.avi"))

print(os.path.isfile(r'V:\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi'))
print(os.path.isfile(r'V:\\FORENSOR DTB Dataset processed\\pow_day_125236_07.5.avi'))
print(os.path.isfile(r'V:/FORENSOR DTB Dataset processed/pow_day_125236_07.5.avi'))

print(os.path.isfile(r'V:\FORENSOR DTB Dataset processed\pow_day_125236_07.5.avi'))
print(os.path.isfile(r'V:\\FORENSOR DTB Dataset processed\\pow_day_125236_07.5.avi'))
print(os.path.isfile(r'V:/FORENSOR DTB Dataset processed/pow_day_125236_07.5.avi'))

This prints:

False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
Tasos
  • 1,575
  • 5
  • 18
  • 44
  • Possible duplicate of [os.path.isfile() returns false for file on network drive](https://stackoverflow.com/questions/39492524/os-path-isfile-returns-false-for-file-on-network-drive) – Sayse Mar 26 '19 at 12:27

1 Answers1

0

maybe this work:

def check(file):
    #try to open file
    try:
        open(file)
    except:
        #if file not exists return false becuse you cant open it
        return False
    else:
        #else return true
        True

just call it and file will be the path to the file and the file name it self

Matthijs990
  • 637
  • 3
  • 26