python copy all files larger than x then rename all new files -
i need script copy files larger 5mb given folder new folder script needs create on desktop. needs rename files in increasing order changing extension. example files: slides.ppt, math.doc, essay.docx to:lec1.doc, lec2.doc, lec3.doc
i got script work , lists files larger 5mb:
import os # directory interested in mypath = "c:\asd" # min size of file in bytes mysize = '5000000' # file paths stored in list fileslist= [] path, subdirs, files in os.walk(mypath): name in files: fileslist.append(os.path.join(path, name)) in fileslist: # getting size in variable filesize = os.path.getsize(str(i)) # print files meet condition if int(filesize) >= int(mysize): print("the file: " + str(i) + " is: " + str(filesize) + " bytes")
now prints out list , list correct how can go here? looked os , glob i'm having hard time figuering out.
thank guys helping out.
dany
try shutil
package. handles high level file operations
import shutil #do shutil.move(source,destination)
where source , destination might files or folders.
set destination final name of file, instead of copying , renaming.
Comments
Post a Comment