Python: Deleting files of a certain age -


Then at this time I'm trying to delete the files listed in the 1 minute old directory, I will change that value one The time I have the script is working. In the code below, there is an error: AttributeError: 'str' object has no attribute in 'mtime'

  import time import OS Oslistdir (folder ) #from path import path for a file in seven_days_ago = time.time () - 60 folder = '/ home / rv / desktop / test': if int (somefile.mtime) & lt; Seven_days_ago: somefile.remove ()  

import time import OS one_minute_ago = time For somefile in Oslistdir ('.') .time () - 60 folder = '/ home / rv / desktop / test' os.chdir (folder): st = os.stat (somefile) mtime = st.st_mtime if meet & Lt; One_mint_go: print ('% s'% somefile delete) # os.unlink (somefile) # unconnected only if you are sure

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -