import os, time, shutil from datetime import date sourceDirHome = "F:\DCIM" TargetDirHome = 'E:\Personnel\Photos' for dirName, subdirList, fileList in os.walk(sourceDirHome): print("Found Directory",dirName) #break for f in fileList: print("File name is:",f) fName = os.path.join(dirName,f) print(fName) ctime = (os.path.getctime(fName)) print("Created On", ctime) fmtTimeYM = time.strftime('%Y-%m',time.localtime(ctime)) fmtTimeY = time.strftime('%Y', time.localtime(ctime)) fmtTimeM = time.strftime('%m', time.localtime(ctime)) print('formatted time: ',fmtTimeYM) tgtpthstrY = os.path.join(TargetDirHome,fmtTimeY) tgtpthstrYM = os.path.join(tgtpthstrY,fmtTimeYM) if os.path.exists(tgtpthstrYM): print(tgtpthstrYM, 'Exists.. copying... 1') shutil.copy(fName,tgtpthstrYM) else: if os.path.exists(tgtpthstrY): print(tgtpthstrYM, 'Does Not Exists.. creating... 2') os.mkdir(fmtTimeYM) shutil.copy(fName, tgtpthstrYM) else: print(tgtpthstrY, 'Does NOt Exists.. creating... 3') os.mkdir(tgtpthstrY) os.mkdir(tgtpthstrYM) shutil.copy(fName, tgtpthstrYM)
all things related to OBIEE, OBIA, Oracle Data Visualization, Big Data , Apache Hadoop, HDFS, Pig, Hive, Impala, R
2020/04/01
File Handling with Python
This little utility is for copying files from source to target directories. On the way it checks whether a directory exists in the target, if not creates and then copies the files.
Subscribe to:
Post Comments (Atom)
File Handling with Python
This little utility is for copying files from source to target directories. On the way it checks whether a directory exists in the target, ...
-
I have been playing around with the OBIEE repository for a demo project at current client assignment. I have been trying to use the "wh...
-
After installing Oracle DVD, I started playing around with the connections to various data sources. With the new release, the connections ...
-
I have been working on a client assignment to implement OBIEE and design and develop dashboards and get them up and running. One particul...
No comments:
Post a Comment