Tag: Directory
C++ : Check if given path is a file or directory using Boost & C++17 FileSystem Library
In this article we will discuss different ways to check if given path is of file or directory that exists using Boost Filesystem Library & C++17 Filesystem Library. Both Boost Filesystem library & C++17 Experimental filesystem library provides certain functions that we are going to use here, Advertisements bool exists(const path& p); In Boost Library’s …
C++ : Check if given path is a file or directory using Boost & C++17 FileSystem LibraryRead More
C++ : Get the list of all files in a given directory and its sub-directories using Boost & C++17
In this article we will discuss how to fetch the recursive list of all files in a given directory using Boost and C++17 FileSystem Library. Suppose we have a directory i.e. Advertisements /home/user/study/tutorials and I want list of all files in this directory and its sub directories, but also want to skip certain directory like …
How to create a Directory in python ?
In this article we will discuss different APIs in python to create directories. Creating a Directory in Python Python’s OS module provides a function to create a directory i.e. Advertisements os.mkdir(path) It creates a directory with given path i.e. os.mkdir(‘tempDir’) It creates the directory ‘tempDir’ in current directory. Frequently Asked: Find the smallest file in …
Python : Get Current Directory
In this article, we will discuss how to get the current working directory in Python. Python’s os module provides a function to get the current working directory i.e. os.getcwd() It returns a string containing the current working directory. For calling this function we need to import os module i.e. Advertisements import os Let’s understand by …
How to change current working directory in python ?
In this article we will discuss how to change the current working directory in python. Current working directory is the directory in which program is running. Advertisements Change Current Working Directory in Python First of all we need to import python’s os module i.e. import os Python’s os module provides a function to change the …
How to change current working directory in python ?Read More
Python : How to get list of files in directory and sub directories
In this article we will discuss different methods to generate a list of all files in directory tree. Creating a list of files in directory and sub directories using os.listdir() Python’s os module provides a function to get the list of files or folder in a directory i.e. Advertisements os.listdir(path=’.’) It returns a list of …
Python : How to get list of files in directory and sub directoriesRead More
Python : How to check if a directory is empty ?
In this article we will discuss different ways to check if a directory is empty or not. Python’s os module provides a function to get the list of files or folder in a directory i.e. Advertisements os.listdir(path=’.’) It returns a list of all the files and sub directories in the given path. Now if the …
How to check if a file or directory or link exists in Python ?
In this article we will discuss techniques in python to check if a file exists or a link or a directory exists or not. Python – Check if a path exists Python’s os module provides a function to check if a given path exists or not i.e. Advertisements os.path.exists(path) It will True if the path …
How to check if a file or directory or link exists in Python ?Read More
Python : How to delete a directory recursively using shutil.rmtree()
In this article we will discuss how to delete an empty directory and also all contents of directory recursively i.e including contents of its sub directories. Delete an empty directory using os.rmdir() Python’s os module provide a function to delete an empty directory i.e. Advertisements os.rmdir(pathOfDir) Path of directory can be relative or absolute. It …
Python : How to delete a directory recursively using shutil.rmtree()Read More
Python: How to create a zip archive from multiple files or Directory
In this article we will discuss how to create a zip archive from selected files or files from a directory based on filters. Python’s zipfile module provides a ZipFile class for zip file related stuff. Let’s use this to create a zip archive file. Advertisements First import the class from module i.e. from zipfile import …
Python: How to create a zip archive from multiple files or DirectoryRead More