Browse Source

Added code for moving files to another folder

Clindo 7 years ago
parent
commit
2771deae1a
5 changed files with 20 additions and 12 deletions
  1. 2 1
      .gitignore
  2. 4 3
      app.py
  3. 13 3
      automate.py
  4. 1 1
      configuration.xml
  5. 0 4
      hello.py

+ 2 - 1
.gitignore

@@ -1 +1,2 @@
-.idea/
+.idea/
+.FirstPython.iml

+ 4 - 3
app.py

@@ -1,10 +1,11 @@
 from automate import Automate
 
-Paths=[]
+
 Files=[]
 Auto = Automate()
 Paths=Auto.Init()
 
-Files=Auto.GetFiles(Paths)
+#Files=Auto.GetFiles(Paths)
+#print (Files)
 
-print (Files)
+Auto.copyFiles(Paths)

+ 13 - 3
automate.py

@@ -1,5 +1,6 @@
 from conf import PathConfig
 import os
+import shutil
 
 
 class Automate:
@@ -8,10 +9,10 @@ class Automate:
     files = []
 
     def Init(self):
-        Path = PathConfig( );
+        Path = PathConfig( )
         FolderPaths = []
-        Path.SetPath( );
-        FolderPaths = Path.getPath( );
+        Path.SetPath( )
+        FolderPaths = Path.getPath( )
         return FolderPaths
         # print (FolderPaths)
 
@@ -19,3 +20,12 @@ class Automate:
         for file in os.listdir( paths[0] ):
             Automate.files.append( file )
         return Automate.files
+
+    def copyFiles(self, paths):
+        for file in os.listdir( paths[0] ):
+            print ("File being moved -----> " + file)
+            full_file_name = os.path.join( paths[0], file )
+            if os.path.isfile(full_file_name):
+                shutil.move( full_file_name, paths[1] )
+
+                #shutil.copy( full_file_name, paths[1] )

+ 1 - 1
configuration.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
 <RootPath>
     <Path value="D:\Master Studies\WS16-17\TKPraktikum\Python Tutorial\test"> </Path>
-    <ConvertedPath value="D:\Master Studies\WS16-17\TKPraktikum\Python Tutorial\test\ConvertedFiles"> </ConvertedPath>
+    <ConvertedPath value="D:\Master Studies\WS16-17\TKPraktikum\Python Tutorial\ConvertedFiles"> </ConvertedPath>
 </RootPath>

+ 0 - 4
hello.py

@@ -1,4 +0,0 @@
-import os
-for file in os.listdir("D:/Master Studies/WS16-17/TKPraktikum/Python Tutorial/test"):
-   # if file.endswith(".*"):
-        print(file)