From 90033e4169a1c63c2334714bf272c2d62b87a308 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Thu, 21 Jan 2010 09:38:35 +0000 Subject: [PATCH] Use shutil.rename if on the same filesystem (move makes a copy first). Suggested by the Python 2.6.4 documentation: http://docs.python.org/library/shutil.html --- autoPathTv.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/autoPathTv.py b/autoPathTv.py index 6207278..a899a13 100755 --- a/autoPathTv.py +++ b/autoPathTv.py @@ -23,7 +23,7 @@ regex_config={} # Path configs # Where to move the files -config['target_path'] = "/Volumes/ionDrive/video/tv/%(file_showname)s/season %(seasno)s/" +config['target_path'] = "/mnt/vault/video/TV Shows/%(file_showname)s/Season %(seasno)s/" ############################################## @@ -232,7 +232,8 @@ def make_path(path): try: os.makedirs(path) except OSError: - print "Couldn't make path" + #print "Couldn't make path" + pass #end make_path def does_file_exist(path): @@ -274,7 +275,7 @@ def main(): print "Old path:", oldfile print "New path:", newfile - ans=confirm() + ans= "always" if ans == "always": opts.always = True if ans or opts.always: @@ -286,14 +287,14 @@ def main(): if same_partition(oldfile, newpath): print "[*] Moving file" try: - shutil.move(oldfile, newpath) + shutil.rename(oldfile, newpath) except Exception, errormsg: print "[!] Error moving file! %s" % (errormsg) #end try else: print "[*] Copying file" try: - copy_with_prog(oldfile, newfile) + shutil.move(oldfile, newfile) except Exception, errormsg: print "[!] Error copying file! %s" % (errormsg) else: