From 6ea3fa32bea39e49b9dcf62540378d13a3a6b4b2 Mon Sep 17 00:00:00 2001 From: Erik Hahn Date: Fri, 31 Jul 2009 14:40:52 +0200 Subject: [PATCH] Implement copy and move actions --- ordnung.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ordnung.py b/ordnung.py index 277c797..a0ca5dd 100644 --- a/ordnung.py +++ b/ordnung.py @@ -1,6 +1,8 @@ from path import path import fnmatch -import os, sys +import os +import shutil +import sys from optparse import OptionParser, OptionGroup from tag_wrapper import tag @@ -13,6 +15,12 @@ def issupportedfile(name): return True return False + +def mkdir(newdir): + if not os.path.isdir(newdir): + os.makedirs(newdir) + + def newpath(file, pattern): # Create the tokens dictionary tokens = {} @@ -105,9 +113,11 @@ def main(): for i in files_to_move(base_dir=base, pattern=pattern, recursive=options.recursive): if options.action == MOVE: - pass #TODO + mkdir(os.path.split(i[1])[0]) + shutil.move(i[0], i[1]) elif options.action == COPY: - os.makedirs(os.path.split(i[1])[0]) + mkdir(os.path.split(i[1])[0]) + shutil.copy2(i[0], i[1]) else: safeprint (i[0] + " --> " + i[1]) -- 2.11.4.GIT