split ( ', ', 1 ) # list sort (modify itself) join (sentence ) #'there is no spoon' list = ', '. count (obj ) # count appearance of obj # array to string and string to array List operation (so-called array) ( ref) len (arrayName ) # size of list # add value to all elements of list Win_copy_process (file_list ,tgt_folder ) GetAnyOperationsAborted ( ) return success and not abortedįile_list = PerformOperations ( ) # ref: /en-us/library/bb775769(v=vs.85).aspxĪborted = pfo. CopyItem (src ,dst ) # Schedule an operation to be performed # ref: (v=vs.85).aspx SHCreateItemFromParsingName (f, None ,shell. SHCreateItemFromParsingName (tgt_folder, None ,shell. FOF_NOCONFIRMATION ) # Set the destionation folderĭst = shell. IID_IFileOperation ) # Respond with Yes to All for any dialog # ref: (v=vs.85).aspx shell import shell ,shellconĭef win_copy_process (src_files ,tgt_folder ): Use system file manager to copy with system progress window (windows) #ref: import pythoncomįrom win32com. extend ( (src, dst, str (why ) ) ) if errors: # can't copy file access times on Windows pass except OSError as why:Įrrors. copystat (src, dst ) except WindowsError: append ( (srcname, dstname, str (why ) ) ) # catch the Error from the recursive copy_tree so that we can # continue with other files except OSError as err: copy2 (srcname, dstname ) # other case like: devices, sockets etc. isdir (srcname ):Ĭopy_tree (srcname, dstname, symlinks ) else: created folders seams not same date, but file same date import os import shutil def copy_tree (src, dst, symlinks = False ): Python more complete version for copy folder and its content # ref: # folder content to target folder content. Result = getDirData (r 'R: \ServerFolder \RootDir', 5 )Įnd = time. Root_len = len (top ) # len(os.p) for root ,dirs ,files in scandir. # detail inf: # can use with maya 2017 by zip out _scandir.pyd and scandir.py: (scandir-1.10.0-cp27-cp27m-win_amd64.whl) Res = elif depth = maxDepth:ĭirs = # Don't recurse any deeper return res walk (top, topdown = True ):ĭepth = root. Root_len = len (top ) # len(os.p) for root ,dirs ,files in os. # ref: # p圓 option: better with scandir, # py2 has: Import os def getDirData ( top, maxDepth = 1 ): extend ( allFiles ) #someFiles.extend( ) return res Res = for d in range ( 1, maxDepth 2 ): Import glob def getDirData (top, maxDepth = 1 ):
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |