mirror of
https://github.com/nikdoof/tvorganise.git
synced 2025-12-13 06:42:16 +00:00
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
This commit is contained in:
@@ -23,7 +23,7 @@ regex_config={}
|
|||||||
# Path configs
|
# Path configs
|
||||||
|
|
||||||
# Where to move the files
|
# 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:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
except OSError:
|
except OSError:
|
||||||
print "Couldn't make path"
|
#print "Couldn't make path"
|
||||||
|
pass
|
||||||
#end make_path
|
#end make_path
|
||||||
|
|
||||||
def does_file_exist(path):
|
def does_file_exist(path):
|
||||||
@@ -274,7 +275,7 @@ def main():
|
|||||||
|
|
||||||
print "Old path:", oldfile
|
print "Old path:", oldfile
|
||||||
print "New path:", newfile
|
print "New path:", newfile
|
||||||
ans=confirm()
|
ans= "always"
|
||||||
if ans == "always": opts.always = True
|
if ans == "always": opts.always = True
|
||||||
|
|
||||||
if ans or opts.always:
|
if ans or opts.always:
|
||||||
@@ -286,14 +287,14 @@ def main():
|
|||||||
if same_partition(oldfile, newpath):
|
if same_partition(oldfile, newpath):
|
||||||
print "[*] Moving file"
|
print "[*] Moving file"
|
||||||
try:
|
try:
|
||||||
shutil.move(oldfile, newpath)
|
shutil.rename(oldfile, newpath)
|
||||||
except Exception, errormsg:
|
except Exception, errormsg:
|
||||||
print "[!] Error moving file! %s" % (errormsg)
|
print "[!] Error moving file! %s" % (errormsg)
|
||||||
#end try
|
#end try
|
||||||
else:
|
else:
|
||||||
print "[*] Copying file"
|
print "[*] Copying file"
|
||||||
try:
|
try:
|
||||||
copy_with_prog(oldfile, newfile)
|
shutil.move(oldfile, newfile)
|
||||||
except Exception, errormsg:
|
except Exception, errormsg:
|
||||||
print "[!] Error copying file! %s" % (errormsg)
|
print "[!] Error copying file! %s" % (errormsg)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user