Python working with files
Python notebooks to automate your work with files. You can use Python to list files in a directory and copy, create, modify, convert, and delete files. The best thing is that Python doesn't get bored or tired even when working with 1000s of files. And it is fast!
Python list files in directory
Python can be used to automate work with files. In this notebook, we will show different ways to list files in the directory with Python. You can exclude directories from list and filter files by extension.
Python delete file
You can use Python to automate file delete in your file system. You can use `os` Python built-in module and `remove()` function. It is a good practice to check if file exists before delete.
Python delete directory
With Python, you can automate operations on files and directories. This notebook shows how to use the Python built-in module `shutil`. It has `rmtree()` function that can be used to remove directories.
Python check file exists
Python has built-in module `os` for interacting with operating system. It has function `exists` to check if file exists. It returns `True` if file exists and `False` otherwise.
Python file copy
Do you need to copy 100s of files? Python is great tool to automate this task. It has built-in module `shutil` with `copy2()` function that can copy file with file's metadata.
Python read file
You can use Python to read files. There are `open()` and `read()` functions for that. They are Python built-in, so no need to install or import of additional modules.
Python write file
Python can be used to write content to file. There are built-in functions `open()` and `write()`. The new file will appear in the selected directory.
Python append to file
You can append file with Python. You need to `open()` file in append mode by passing `a` as second argument. Use `write()` function to append new content.