Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8216289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:04:33+00:00 2026-06-07T12:04:33+00:00

I can’t figure out how to write script that backpus only files that were

  • 0

I can’t figure out how to write script that backpus only files that were created or modified previous day. So if I start script on 25.07 at 15:30, it backups files between 24.07 00:00 and 25.07 00:00.
If it is possible preffered way is by using robocopy. I know for /maxage -1 switch but it works for files that are 1 day old counting form the time script was started (problem is because it includes files from current day also).

set source="C:\Folder1"
set destination="F:\Folder2"
robocopy %source% %destination% /z /MAXAGE: -1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:04:35+00:00Added an answer on June 7, 2026 at 12:04 pm

    Robocopy gives you two options for specifying dates (for maxage, minage, maxlad, minlad) – either relative (n<1900) or fixed dates (otherwise, treated as yyyymmdd). Full syntax here.

    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:

    1. Exclude files unused since yesterday: use /maxlad (today_date – 1 day)

    2. Exclude files used today: use /minlad (today_date)

    Put those together:
    robocopy source_dir destination_dir file_spec /maxlad:%today_minus_1% /minlad:%today%

    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. here) or write it yourself.

    If you can use powershell it’s pretty simple:
    for /f %y in ('powershell get-date ^(get-date^).adddays^(-1^) -uformat %Y%m%d') do set today_minus_1=%y gets you first, and

    for /f %t in ('powershell get-date -uformat %Y%m%d') do set today=%t second variable.

    So to summarize: set your date vars and then run robocopy (using them in excludes). It’s worth to use /L option when checking if it works properly, as actual copy will re-set access timestamps on your files!

    All vars and commands given as if executed directly from cmd line. If used in batch you will need to add some % (and probably wise to use setlocal)

    Note: version I use (XP010) does not allow to use negative numbers or space as in your example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can't figure out how to do this in a pretty way : I have
Can't seem to figure out what's wrong with the simple getJSON call below. It's
Can a LINQ enabled app run on a machine that only has the .NET
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
can someone explain why the compiler accepts only this code template<typename L, size_t offset,
Can we change the color of the divider? Apple documentations says, that we can
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Can't work out a way to make an array of buttons in android. This
Can anyone help me with an excel formula that groups related rows and creates
Can anyone help me trying to find out why this doesn't work. The brushes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.