File Manipulation with Python

File Manipulation, Python
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] Batch Folder Creation If you want to create a handful of folders / directories, it's not difficult to manually do so.  But creating a few dozen folders manually gets mundane really fast. The os package contains a method, os.mkdir, that we can use in our situation. One line of code you might (though not required) want to use before you start is to change your working directory to where you want to create your list of folders: [code lang="python"] os.chdir('C:/Users/USERNAME/Documents') [/code] One problem I've…
Read More