I am attempting to find folders based on their last modified dates. I can get the dates and folders (or directory names) but I'm unsure as to the best way to check that they are before a certain date.
So far I have:
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016年11月20日", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
modifiedDate = time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name)))
strLastModified = datetime.datetime.strptime(modifiedDate, '%Y/%m/%d')
if strLastModified > archiveDate:
print name
However this doesn't feel like it's right, as I don't think I'm comparing them correctly. Could someone advise if I'm going about this the right way?
Actually I might have an answer for this, but if you still feel it's the wrong way please let me know.
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016年11月20日", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
modifiedDate = time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name)))
strLastModified = datetime.datetime.strptime(modifiedDate, '%Y/%m/%d')
if strLastModified > archiveDate:
print name
This is what I've got and it seems to be right in that they're comparing the same attributes. If If there is a better, more pythonicPythonic way for this, please advise :).
I am attempting to find folders based on their last modified dates. I can get the dates and folders (or directory names) but I'm unsure as to the best way to check that they are before a certain date.
So far I have:
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016年11月20日", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
modifiedDate = time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name)))
strLastModified = datetime.datetime.strptime(modifiedDate, '%Y/%m/%d')
if strLastModified > archiveDate:
print name
However this doesn't feel like it's right, as I don't think I'm comparing them correctly. Could someone advise if I'm going about this the right way?
Actually I might have an answer for this, but if you still feel it's the wrong way please let me know.
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016年11月20日", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
modifiedDate = time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name)))
strLastModified = datetime.datetime.strptime(modifiedDate, '%Y/%m/%d')
if strLastModified > archiveDate:
print name
This is what I've got and it seems to be right in that they're comparing the same attributes. If there is a better more pythonic way for this please advise :)
I am attempting to find folders based on their last modified dates.
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016年11月20日", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
modifiedDate = time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name)))
strLastModified = datetime.datetime.strptime(modifiedDate, '%Y/%m/%d')
if strLastModified > archiveDate:
print name
This is what I've got and it seems to be right in that they're comparing the same attributes. If there is a better, more Pythonic way for this, please advise.
I am attempting to find folders based on their last modified dates. I can get the dates and folders (or directory names) but I'm unsure as to the best way to check that they are before a certain date.
So far I have:
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016年11月20日", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
modifiedDate = time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name)))
strLastModified = datetime.datetime.strptime(modifiedDate, '%Y/%m/%d')
if strLastModified > archiveDate:
print name
However this doesn't feel like it's right, as I don't think I'm comparing them correctly. Could someone advise if I'm going about this the right way?
Actually I might have an answer for this, but if you still feel it's the wrong way please let me know.
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016年11月20日", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
modifiedDate = time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name)))
strLastModified = datetime.datetime.strptime(modifiedDate, '%Y/%m/%d')
if strLastModified > archiveDate:
print name
This is what I've got and it seems to be right in that they're comparing the same attributes. If there is a better more pythonic way for this please advise :)
I am attempting to find folders based on their last modified dates. I can get the dates and folders (or directory names) but I'm unsure as to the best way to check that they are before a certain date.
So far I have:
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016年11月20日", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
modifiedDate = time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name)))
strLastModified = datetime.datetime.strptime(modifiedDate, '%Y/%m/%d')
if strLastModified > archiveDate:
print name
However this doesn't feel like it's right, as I don't think I'm comparing them correctly. Could someone advise if I'm going about this the right way?
I am attempting to find folders based on their last modified dates. I can get the dates and folders (or directory names) but I'm unsure as to the best way to check that they are before a certain date.
So far I have:
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016年11月20日", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
modifiedDate = time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name)))
strLastModified = datetime.datetime.strptime(modifiedDate, '%Y/%m/%d')
if strLastModified > archiveDate:
print name
However this doesn't feel like it's right, as I don't think I'm comparing them correctly. Could someone advise if I'm going about this the right way?
Actually I might have an answer for this, but if you still feel it's the wrong way please let me know.
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016年11月20日", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
modifiedDate = time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name)))
strLastModified = datetime.datetime.strptime(modifiedDate, '%Y/%m/%d')
if strLastModified > archiveDate:
print name
This is what I've got and it seems to be right in that they're comparing the same attributes. If there is a better more pythonic way for this please advise :)
I am attempting to find folders based on their last modified dates. I can get the dates and folders (or directory names) but I'm unsure as to the best way to check that they are before a certain date.
So far I have:
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Folder"\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016年11月20日", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
ifmodifiedDate = time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name))) > 2016 strLastModified = datetime.datetime.strptime(modifiedDate, '%Y/11%m/20%d')
if strLastModified > archiveDate:
print name
However this doesn't feel like it's right, as I don't think I'm comparing them correctly. Could someone advise if I'm going about this the right way?
I am attempting to find folders based on their last modified dates. I can get the dates and folders (or directory names) but I'm unsure as to the best way to check that they are before a certain date.
So far I have:
import os, shutil, stat, errno, time
srcFolders = "C:\Users\Test\Desktop\Folder"
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
if time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name))) > 2016/11/20:
print name
However this doesn't feel like it's right, as I don't think I'm comparing them correctly. Could someone advise if I'm going about this the right way?
I am attempting to find folders based on their last modified dates. I can get the dates and folders (or directory names) but I'm unsure as to the best way to check that they are before a certain date.
So far I have:
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016年11月20日", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
modifiedDate = time.strftime('%Y/%m/%d', time.gmtime(os.path.getmtime(name))) strLastModified = datetime.datetime.strptime(modifiedDate, '%Y/%m/%d')
if strLastModified > archiveDate:
print name
However this doesn't feel like it's right, as I don't think I'm comparing them correctly. Could someone advise if I'm going about this the right way?