File Manipulation with Python
Getting started Python is great for automating file creation, deletion, and other types of file manipulations. Two of the primary packages used to perform these types of tasks are os and shutil. We'll be covering a few useful highlights from each of these. [code lang="python"] import os import shutil [/code] How to get and change your current working directory You can get your current working directory using os.getcwd: [code lang="python"] os.getcwd() [/code] Any actions you take without specifying a directory will be assumed to be associated with your current working directory i.e. if you create or search for a file without specifying a directory, Python will assume you're in the value of os.getcwd(). To change your working directory, use os.chdir: [code lang="python"] os.chdir("C:/path/to/new/directory") [/code] How to merge a directory name…