Created
August 10, 2016 19:30
-
-
Save jeffgerhard/72eda81f1adfeccde70ae8ad51a29fb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cleans up the downloaded, bagged masters | |
# and moves to archival storage | |
# | |
# could combine this with the IA download script? | |
# | |
# leaves behind a log file with the id's to plug them into the Access db | |
import os | |
import shutil | |
from tkinter.filedialog import askdirectory | |
#from tkinter import messagebox | |
#from sys import exit | |
#from shutil import rmtree | |
def get_subdirectories(a_dir): | |
# stackoverflow.com/questions/800197/how-to-get-all-of-the-immediate-subdirectories-in-python#800201 | |
return [name for name in os.listdir(a_dir) | |
if os.path.isdir(os.path.join(a_dir, name))] | |
dirname = askdirectory(title='directory to move', initialdir='Z:\\holding\\books\\IA_download\\') | |
m_dir='Z:\\archival_master_files\\books\\general_collection\\' | |
dirlist = get_subdirectories(dirname) | |
warningslist = [] | |
logname = os.path.join(dirname, "log.txt") | |
for d in dirlist: | |
with open(logname, 'a') as fh: | |
fh.write(d[:-7] + '\n') | |
localdir = os.path.join(dirname, d) | |
dest = os.path.join(m_dir, d) | |
shutil.move(localdir,dest) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment