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

  • SEARCH
  • Home
  • 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 9270391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:21:29+00:00 2026-06-18T15:21:29+00:00

My script so far: @ECHO OFF XCOPY C:\Users\Jeremy\Documents\* I:\Jeremy’s%1Desktop\My%~1Documents /s /i /h Trying to

  • 0

My script so far:

@ECHO OFF
XCOPY   C:\Users\Jeremy\Documents\* I:\Jeremy's%1Desktop\My%~1Documents /s /i /h

Trying to create a “backup script” that will transfer all of the files from my entire “Jeremy” directory to my external harddrive. (Want to not transfer some hidden files in some folders but do transfer hidden files in another folder) so I don’t know how to accomplish that either.

Anyway I want to instead of having it prompt me everytime to overwrite a file, i’d like to set it to overwrite if larger or if newer (hence the timestamp). I am unsure of how to set this and set overwrite if timestamp say’s newer. Thank you for your help, as you can see two lines in I’m having a hard time.

Thanks!

  • 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-18T15:21:31+00:00Added an answer on June 18, 2026 at 3:21 pm

    See ROBOCOPY for advanced copy-options (e.g. /XO = exclude older files).

    With COPY or XCOPY, you will have to loop through the files manually and copy them individually after performing your tests.

    Loop (recursively) through files in a folder:

    for /r "%directory%" %%f in (*.*) do (
      rem ... do sth with file %%f
    )
    

    You can also get for example the names/directories of the files with %~nf or %~df

    Get date/time of file:

    for /f %f in ("%file%") do (
       set timestamp=%~tf
       set day=%timestamp:~0,2%"
       set month=%timestamp:~3,2%"
       rem ... etc.
    )
    

    Get current date/time:

    echo Date: %date% rem (or: set currentdate=%date%)
    echo Time: %time%
    

    You would have to implement the comparison yourself (first compare year, then compare month, then… etc.) This could be a little tricky, or a lot of work at least.

    To check if a file is hidden:

    for /f "delims=" %%a in ('attrib "%file%"') do (
        set attribs=%%a
        if "!attribs:~4,1!"=="H" rem ... file is hidden
    )
    

    Don’t forget to set this at the beginning of your batch:

    setlocal enabledelayedexpansion
    

    This ensures that you can set/read variables within a loop. Use !variable! instead of %variable% then.

    These are just the basic tools, there’s still a lot of work to do and some pitfalls to work around. You should really consider using ROBOCOPY.

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

Sidebar

Related Questions

So far i have an assembly script that lets you boot from it and
I'm trying to write a Perl script that will work better with KDE's kwrited
this is some of my script so far: $check = (SELECT username FROM users
I'm trying to write a bash script that will run on both Mac and
I'm trying to do a quick and simple game backup script and it's not
I'm trying to write a cmd script that gets the current date and time
I am trying to write a script that will read a remote sitemap.xml and
I'm trying to create a script to compile an Windows Forms C# 2.0 project
I am attempting to create a php script that can connect thru ssh to
i'm trying to create a zip script based on what I've found here but

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.