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 7043377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:16:54+00:00 2026-05-28T02:16:54+00:00

I have something that makes a new folder with files in every night. Does

  • 0

I have something that makes a new folder with files in every night. Does anyone know how to create a script that will copy the content of the newest/latest folder to a network share and overwrite any of the files and folders in the network share? Been scratching my head for awhile.

Thanks in advance.

  • 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-05-28T02:16:55+00:00Added an answer on May 28, 2026 at 2:16 am

    Something like this might serve your purpose:

    SET "src_root=D:\root\for\source\directories"
    SET "tgt_path=\\NETWORK\SHARE\target\path"
    
    DIR "%src_root%" /B /AD /O-D /TC > "%TEMP%\dirlist.tmp"
    < "%TEMP%\dirlist.tmp" SET /P last_dir=
    
    FOR /D %%I IN ("%tgt_path%\*") DO RD "%%I" /S /Q
    DEL "%tgt_path%\*" /Q
    
    XCOPY "%src_root%\%last_dir%\*" "%tgt_path%" /S /E
    

    The src_root variable is supposed to contain the path to the folder where your daily folders are created, and tgt_path is the target path for the latest folder’s contents to copy.

    The DIR command is set up to return the contents of the root folder in the following manner:

    • no extra information in the output, only names (/B);

    • no files, just folders (/AD);

    • sort (/O…) the output in the descending (…-…) order of folder date (…D);

    • the date is that of the folder’s creation (/TC).

    The output is redirected to a temporary file, whose first line is then read into a variable (the SET /P command). That piece of information, together with the root path and the target path, is ultimately used first with deleting, then with copying files.

    The deleting is done in two steps: first the folders (the RD command in the FOR /D loop), then the files (DEL). I’d like to note at this point that this script doesn’t assume intervention at any stage on your side, which I understood was your intention. Consequently, it doesn’t expect a confirmation to delete the files and folders at the target path, so, when you run the script, the old contents will be deleted silently (which is the effect of the /Q switch used with both RD and DEL).

    The copying is done with XCOPY, as it allows us to retain the structure of the source folder (the /S switch), including empty subdirectories (/E), if any.

    You can get more information on every command mentioned here by invoking any of them with the /? switch at the command prompt.

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

Sidebar

Related Questions

Today I discovered something that makes me sad: objects of type System.Generic.Collections.List don't have
Let's say i have 2 files located in the same folder. /Test/View.cshtml <h1>File that
Anyone know what a virgin /usr/local folder would look like on a brand new
I have something that looks like the following: var someList = MockRepository.GenerateStub<IList<ISomething>>(); someList.Add(MockRepository.GenerateStub<ISomething>()); The
I have something that looks like the following: [CoolnessFactor] interface IThing {} class Tester
I have something that looks like this: As you can see, Blambo is a
i have something that requires a matrix of values, similar to pokemon: (source: firechao.com
Now I have something that I have not seen it before: the database is
Is there any way to have something that looks just like a file on
In my code, I have something that looks like this: @implementation MyClass - (id)

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.