From 5b26210ddef6b830bc67303662802459d47d2dc0 Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Mon, 27 Jan 2014 22:41:40 -0800 Subject: [PATCH] Copy file instead of moving to prevent Invalid cross-device link error --- bin/mv-to-docs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/mv-to-docs b/bin/mv-to-docs index e958080..263d933 100755 --- a/bin/mv-to-docs +++ b/bin/mv-to-docs @@ -6,6 +6,7 @@ Move a document to the correct documents folder import filecmp import os import re +import shutil import sys from datetime import date @@ -64,7 +65,8 @@ if __name__ == "__main__": if not os.path.isfile(new_file_path): print "Moving file '%s' to '%s'" % (file_name, new_file_path) - os.rename(file_name, new_file_path) + shutil.copyfile(file_name, new_file_path) + os.unlink(file_name) else: if filecmp.cmp(new_file_path, file_name): print "Two files already exist and are same: '%s' and '%s'" % \