About 43,000 results
Open links in new tab
  1. How do I check whether a file exists without exceptions?

    Also check other function family members like os.path.isfile, os.path.isdir, os.path.lexists for slightly different behaviors: Return True if path refers to an existing path or an open file descriptor.

  2. How do I get the full path of the current file's directory?

    2812 The special variable __file__ contains the path to the current file. From that we can get the directory using either pathlib or the os.path module. Python 3 For the directory of the script being run:

  3. Better way to check if a Path is a File or a Directory?

    Can someone edit the question title to specify "existing" file/directory? All of the answers apply to a path for a file/directory that is on disk.

  4. How to check if a directory exists in %PATH% - Stack Overflow

    In the folder you are going to search the PATH variable for, create a temporary file with such an unusual name that you would never ever expect any other file on your computer to have.

  5. linux - How to get full path of a file? - Stack Overflow

    On Windows: Holding Shift and right clicking on a file in Windows Explorer gives you an option called Copy as Path. This will copy the full path of the file to clipboard. On Linux: You can use the …

  6. A better way to check if a path exists or not in PowerShell

    Aug 8, 2015 · Mathias R. Jessen Over a year ago @Eris question specifically asks to check if a file exists or not Eris Over a year ago

  7. How can I check the extension of a file? - Stack Overflow

    Sep 30, 2019 · You should make sure the "file" isn't actually a folder before checking the extension. Some of the answers above don't account for folder names with periods. (folder.mp3 is a valid folder …

  8. How do I check if a file exists in Java? - Stack Overflow

    It actually represents a directory path or a file path , and the abstract path it represents does not have to exist physically on your computer . It is just a representation , that`s why , you can enter a path of a …

  9. how to check if a file is a directory or regular file in python?

    Jul 18, 2016 · Technically, all file system objects are files. A directory is a file but of a special type on most file systems. Then there are devices, pipes, sockets, etc. The os.stat() method in this answer is …

  10. Find the current directory and file's directory [duplicate]

    393 Current working directory: os.getcwd() And the __file__ attribute can help you find out where the file you are executing is located. This Stack Overflow post explains everything: How do I get the path of …