# page 69 OS Module important module import os # low level module # getcwd() get your current directory in the current env current_directory = os.getcwd() print("Current directory: ", current_directory) # Listing files and directory files = os.listdir(current_directory) print(files) # as a [] print("-----") for file in files: print(file) print("-----") # Create a directory from datetime import datetime #datetime time date timedelta current_datetime = datetime.now() current_month = current_datetime.month #month() object month value print(current_month) #12 current_year = current_datetime.year # 2023 print(current_year) new_directory = "Log Files for " + str(current_month) + str(current_year) #os.mkdir(new_directory) # Rename object original_filename = "document.pdf" # exists copy_filename = "copy_" + original_filename processed_filename = "processed_" + original_filename # copy the original file BEFORE rename it import shutil # low level module Standard #shutil.copy(original_filename,copy_filename) # OBJECT copy # os.rename(original_filename, processed_filename) # Path join() working_directory = "C:/working/" archive_directory = "C:/archive/" working_full_path = os.path.join(working_directory, original_filename) archive_full_path = os.path.join(archive_directory, original_filename) shutil.copy(working_full_path, archive_full_path)