- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
import fnmatch,os,datetime,time,re,shutil,sys
def find(pattern, startdir=os.curdir):
for (thisDir, subsHere, filesHere) in os.walk(startdir): #
for name in subsHere + filesHere:
if fnmatch.fnmatch(name,pattern):
fullpath = os.path.join(thisDir,name)
yield fullpath
def timeconvert(x):
convert = time.strftime("%Y-%m-%d",time.localtime(os.path.getctime(x)))
return convert
print("select action: delete: delete files: copy: copy files: view: view files")
action = input(" ")
if action == "copy":
print("inter path")
dest = input(" ")
else:
print ("inter date")
cursive = input("")
optime = re.search('20[0-12]\d{1,2}.\d{1,2}',cursive)
if optime == None:
print ('error')
else:
if __name__== '__main__':
import sys
namepattern,startdir, = sys.argv[1],sys.argv[2]
for name in find(namepattern,startdir):
if not str(cursive) <= timeconvert(name):
if action == 'copy':
shutil.copy(name, dest)
elif action == 'delete':
os.remove(name)
elif action == "view":
print(name + timeconvert(name))
else:
print ('error')
Комментарии (0) RSS
Добавить комментарий