diff --git a/crawl_subject_files.py b/crawl_subject_files.py index 6fad069..4e04873 100644 --- a/crawl_subject_files.py +++ b/crawl_subject_files.py @@ -376,7 +376,6 @@ def audio_wav_window(self): def crawl_files(self, file_or_dirname): self.start_button.config(state="disable") self.tups=[] - print(self.chosen_subjects) if self.recurse_or_scan.get(): if not file_or_dirname.endswith('.csv'): tkMessageBox.showinfo("Error", "You must provide a csv file to scan or uncheck the top box.") @@ -473,8 +472,8 @@ def copy_files(self, lst): else: for tup in lst: filepath = tup[0] - localdir = os.path.dirname(filepath) - savepath = self.output_dir+localdir + drive, localdir = os.path.splitdrive(filepath) + savepath = os.path.join(self.output_dir,os.path.normpath(os.path.dirname(localdir)).lstrip(r"\\").lstrip("/")) try: with open(savepath) as f: pass except IOError as e: diff --git a/mirror_script/mirror_directory.py b/mirror_script/mirror_directory.py index 6e6e3b3..0121cae 100644 --- a/mirror_script/mirror_directory.py +++ b/mirror_script/mirror_directory.py @@ -7,7 +7,7 @@ import Tkinter as tk # for python2 import tkFileDialog as tkfiledialog import tkMessageBox - from Tkinter import ttk + import ttk except ImportError: import tkinter as tk # for python3 import tkinter.filedialog as tkfiledialog @@ -117,7 +117,7 @@ def mirror_files(self, lst): def mirror_files_to_csv(self, lst): self.getSavePath() x = self.save_filename - if not re.match("(.csv)$", self.save_filename): + if not x.endswith('.csv'): x+=".csv" with open(self.output_dir+'/'+x, 'a') as f: writer = csv.writer(f) @@ -130,8 +130,8 @@ def mirror_files_recursive(self, lst): for tup in lst: filepath = tup[0] base_name = os.path.basename(filepath) - localdir = os.path.dirname(filepath) - savepath = os.path.join(self.output_dir,localdir[1:]) + drive, localdir = os.path.splitdrive(filepath) + savepath = os.path.join(self.output_dir,os.path.normpath(os.path.dirname(localdir)).lstrip(r"\\").lstrip("/")) try: with open(savepath): pass except IOError: @@ -139,7 +139,10 @@ def mirror_files_recursive(self, lst): os.makedirs(savepath) pathBefore = os.getcwd() os.chdir(savepath) - subprocess.call(['touch', base_name]) + try: + subprocess.call(['touch', base_name]) + except WindowsError: + open(base_name,'a').close() os.chdir(pathBefore) tkMessageBox.showinfo("Completed", "Directory successfully mirrored!")