spython script to list all of the files and directories that have been created
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Without giving you the entire answer, here are the parts you need:
os.walk('.')iterates over all of the files and directories in.and any of its subdirectories. You can wrap aforloop around that. Look at the examples to get theos.path.join(dirpath, filename)and other details right.os.stat(pathname)returns astatobject with information about the file atpathname. Depending on your platform, eitherst_ctimeorst_birthtimemay be the creation time. (On some platforms, there is no way to get it.) The format is seconds since the epoch.starttime - create time <= X * 60is new. (But make sure you get the timezone stuff right—use either GMT or local time for both file times and current times.)