@@ -452,11 +452,11 @@ def subcmd_archive(args,cfg,arch,aws):
452
452
SELECTEDFILE = os .path .join (hsfolder , retline [0 ])
453
453
else :
454
454
SELECTEDFILE = os .path .join (hsfolder , csv_files [0 ])
455
- if args .larger > 0 and args .older > 0 :
455
+ if args .larger > 0 and ( args .older > 0 or args . newer > 0 ) :
456
456
# implement archiving batchmode
457
457
arch .archive_batch ()
458
458
return
459
- elif args .larger > 0 or args .older > 0 :
459
+ elif args .larger > 0 or args .older > 0 or args . newer > 0 :
460
460
print ('You need to combine both "--older <days> and --larger <GiB> options' )
461
461
return
462
462
@@ -1211,7 +1211,14 @@ def archive_batch(self):
1211
1211
conn .execute (f"CREATE TABLE hs AS SELECT * FROM read_csv_auto('{ SELECTEDFILE } ')" )
1212
1212
1213
1213
# Now, you can run SQL queries on this virtual table
1214
- rows = conn .execute (f"SELECT * FROM hs WHERE { agefld } > { args .older } and GiB > { args .larger } " ).fetchall ()
1214
+ if args .older > 0 :
1215
+ rows = conn .execute (f"SELECT * FROM hs WHERE { agefld } > { args .older } and GiB > { args .larger } " ).fetchall ()
1216
+ elif args .newer > 0 :
1217
+ rows = conn .execute (f"SELECT * FROM hs WHERE { agefld } < { args .newer } and GiB > { args .larger } " ).fetchall ()
1218
+ else :
1219
+ print ('You must either specify --older or --newer' )
1220
+ conn .close ()
1221
+ return False
1215
1222
1216
1223
totalspace = 0
1217
1224
cmdline = ""
@@ -5443,6 +5450,15 @@ def parse_arguments():
5443
5450
options are set froster will print a command that
5444
5451
allows you to archive all matching folders at once.
5445
5452
''' ))
5453
+ parser_archive .add_argument ('--newer' , '-w' , dest = 'newer' , type = int , action = 'store' , default = 0 ,
5454
+ help = textwrap .dedent (f'''
5455
+ Archive folders that have been accessed within the last
5456
+ <days>. (optionally set --mtime to select folders that
5457
+ have not been modified more than <days>). This option
5458
+ works in conjunction with --larger <GiB>. If both
5459
+ options are set froster will print a command that
5460
+ allows you to archive all matching folders at once.
5461
+ ''' ))
5446
5462
parser_archive .add_argument ( '--mtime' , '-m' , dest = 'agemtime' , action = 'store_true' , default = False ,
5447
5463
help = "Use modified file time (mtime) instead of accessed time (atime)" )
5448
5464
parser_archive .add_argument ( '--recursive' , '-r' , dest = 'recursive' , action = 'store_true' , default = False ,
0 commit comments