Answers for "check if folder exists"

79

python check if file exists

import os

os.path.exists("file.txt") # Or folder, will return true or false
Posted by: Guest on February-14-2020
18

node check if file exists

const fs = require("fs"); // Or `import fs from "fs";` with ESM
if (fs.existsSync(path)) {
    // Do something
}
Posted by: Guest on May-22-2020
21

python check if folder exists

import os
print(os.path.isdir("/home/el"))
print(os.path.exists("/home/el/myfile.txt"))
Posted by: Guest on June-20-2020
8

linux command if directory exists

DIR="/etc/httpd/"
if [ -d "$DIR" ]; then
  ### Take action if $DIR exists ###
  echo "Installing config files in ${DIR}..."
else
  ###  Control will jump here if $DIR does NOT exists ###
  echo "Error: ${DIR} not found. Can not continue."
  exit 1
fi
Posted by: Guest on October-22-2020
1

cmd check if folder exists or not

if exist yourfoldername\ (
  echo Yes 
) else (
  echo No
)
Posted by: Guest on August-26-2021
6

how to check if file exists pyuthon

import os
file_exists = os.path.exists("example.txt") # Returns boolean representing whether or not the file exists
Posted by: Guest on September-15-2020

Code answers related to "check if folder exists"

Code answers related to "Javascript"

Browse Popular Code Answers by Language