So to summarize: set your date vars and then run robocopy (using them in excludes). If you can use powershell it's pretty simple:įor /f %y in ('powershell get-date ^(get-date^).adddays^(-1^) -uformat %Y%m%d') do set today_minus_1=%y gets you first, andįor /f %t in ('powershell get-date -uformat %Y%m%d') do set today=%t second variable. Today and today_minus_1 vars must be dates in yyyymmdd format (eg.20120710) - how to get them? Well, if you're constrained to pure batch you would have to find scripts to do the math for you, there are some available (eg. Robocopy source_dir destination_dir file_spec /maxlad:%today_minus_1% /minlad:%today% Exclude files used today: use /minlad (today_date) Exclude files unused since yesterday: use /maxlad (today_date - 1 day)Ģ. You want to include files created or accessed on given date so you have to use min/max lad (last access date) and fixed dates, so let's specify your criteria using robocopy syntax:ġ. Robocopy gives you two options for specifying dates (for maxage, minage, maxlad, minlad) - either relative (n<1900) or fixed dates (otherwise, treated as yyyymmdd).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |