Windows 7 script

Hey guys- is there any Windows 7 CMD script wizard?!

I have a small need but unsure where to find an answer.

Basically I need a batch file to run in CMD (a scheduled task) that :

  • from the folder it’s in, copy all the files with a specific extension (picking inside subfolders), created today, and copies them in a network destination (another machine in the same net)
    I have to run it every day twice.

Please-- any help? I’m cool with hardware but with scripts I’m lagging behind.

I think xcopy is what you’re after. I use this line to copy all new files from source to target:

xcopy /d /y F:\beta_repo\UnsungBetaPBO\addons F:\beta_repo\raw\@unsung_beta\addons

You might want to check out some help site for xcopy though.

Not sure how to run windows 7 scripts periodically though, there is task scheduler, but I never used it.

Good luck,

1 Like

The “running of the script” I know how to do it- that’s the easy part.
Task scheduler takes care of that.

What I need is a simple script that browse the whole folder and subfolders I hardcode into the script itself and extract the files created “today”. Every “today” I run the script.

I have few questions.
In your example…
/d is a date operator,so putting nothing specifies today?
/y suppresses any input from the user, right?

This part…


is the source.
I can write \foldername\*.mdl right? and it would search in all its subfolders?

Perhaps Advanced Task Scheduler from would work…

1 Like

I have to use what’s there, no buying of software… :frowning:

According to xcopy | Microsoft Learn
/d copies all changed files:

Copies source files changed on or after the specified date only. If you do not include a MM-DD-YYYY value, xcopy copies all Source files that are newer than existing Destination files. This command-line option allows you to update files that have changed.

The /y removes the need for answering yes for overwriting files. For my use case to update a build directory from a svn source this is good enough.

If you really need to copy the last day, you need to somehow get ‘yesterday’ and store it in a variable and feed into xcopy. Not sure how to do that exactly. If you can use powershell instead of cmd, it might be as easy as

$a = (get-date).AddDays(-1)


Very good- but how do I specify files in subfolders?
Like- in your case Addons has a number of subfolders and I want to extract fro mall of those all the .txt files?

According to the help page, my bet is on

/s Copies directories and subdirectories, unless they are empty. If you omit /s , xcopy works within a single directory

I don’t need to copy recursively, so have never tried it.

Point is- that doesn’t copy only the files but the folder structure as well.
I only need the files.

Didn’t get that, according to superuser, powershell can help:

Get-ChildItem C:\sourcefolder -Recurse -Filter “*.png” | Copy-Item -destination C:\destinationfolder\

With powershell get-childitem you don’t need xcopy it seems, see How to Use Get-ChildItem to Find Files by Date and Time | PDQ

Get-ChildItem | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)}

Should be modified to -gt … AddDays(-1)

good luck,

1 Like

So- just because I’m thick…

Get-ChildItem source -Recurse -Filter “*.jpg” | Copy-Item -destination destination | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-1)}

is that how’s supposed to work?
Also- is there a way to make it self contained like a .bat?

Basically… like this works- except for one thing.

Get-ChildItem c:\source -Recurse -Filter “*.jpg” | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-1)} | Copy-Item -destination C:\destination

It doesn’t care for the date and copies everything with the right extension from the right source to the right destinaton…

I believe you just need to change -lt to -gt in the Where-Object clause. Right now you are copying everything older than a day.

I believe .ps1 is the correct windows ending for a powershell script, so you could store it in


1 Like


I forgot to thank you a couple more times! :slight_smile:

You truly saved my skin here… :wink:
I owe you one.

1 Like

Lol, wish I actually understood what I just read.


1 Like

To be fair, once you get into it- and separate it bits by bits, it’s quite simple to read.
That said it can be tricky to write unless you constantly practice.

Which I didn’t my bad.

1 Like

I don’t understand most Windows code, simply because I don’t take the time to learn, but I do I understand G code and M code machine tool programming fairly well. As you mention about Windows code the G code is fairly easy to read if you break it down by individual code and use it regularly but it is easy to forget otherwise.

G Code:

G code is fairly set across machine types but quite a few of the M code’s are machine dependent and the same code will be used for different functions on different types of machines.

M Code:


1 Like