Avatar of jimmy6154
jimmy6154 asked on

Logon script to run new files in a dir for people if they havn't ran them before...

So I hope I can explain this well enough for people to get. I am very bad at this sometime.

 So I have a group in my company that drops files in a specific location(I'll call this the "home" directory from now on). From this "home" location when there is a new addition to the folder. Each individual in a remote office runs a small .bat file (the name is never the same). The bat file does some minimal tasks like reg's dll's and copy's the files from the "home" folder to the persons local drive which is the same location. So I would like to try to automate this task via a logon script.

Things it needs to do:
Check the "home" folder for new files. If new files are there, run the .bat file.
Compare what the user has on the local drive with whats in the "home" folder. If there is discrepancy's, run what needs to be ran so that user is up to date.

I found the attached code for a DOS .bat file that sort of does what I was looking to do, but could not get it to work. I'm also not hard set on keeping the folder structure, so if you come up with something that moves files into a "processed" folder or something like that, thats ok with me.

thanks again and please ask questions if this does not make any sense.


:: CTULD.bat
:: Copies Files Modified or Created Today
::  to the Upload Directory, or Copies
::   from the Specified Date Forward
                                              If no Date is Given, Today's
IF "%1" == "" GOTO COPY-TODAY                    Files will be Copied
IF NOT "%1" == "" GOTO COPY-DATE              Otherwise, Files will be Copied
                                                 Forward of the Date Typed
:COPY-TODAY                                   (See Text, Below)
XCOPY *.* C:\UPLOAD /D:%CUR-DATE% < NUL       Copies Files based on
                                                 Today's Date
                                                 ("NUL" Hides Screen Messages)
:COPY-DATE                                     Copies Files based on
XCOPY *.* C:\UPLOAD /D:%1 /-Y                     The Date Given at the
                                                  Command Line
ECHO.                                          Separates the Listing
CALL C:\BATCH\DR.BAT C:\UPLOAD                 Gives a Listing for the
                                                  UPLOAD Directory to
                                                  Show the Operation's Success
SET CUR-DATE=                                  Removes the Date Variable
                                                 From the Environment
DEL CUR-DATE.BAT                                  Deletes the
DEL CURRENT.BAT                                            Temporary Batch Files

Open in new window

Visual Basic ClassicMicrosoft DOSWindows Batch

Avatar of undefined
Last Comment
Steve Knight

8/22/2022 - Mon

at first glance, you may be making this harder on yourself than you need to.

xcopy /d (no additional arguements) will compare the file dates of the source and target destinations.  if the source is newer, it will overwrite the target.


c:\dir1\file1  has a date of 1/1/08
c:\dir1\dir2\file1 has a date of 1/1/08

d:\dir1\file1 has a date of 12/4/07
d:\dir1\dir2\file1 has a date of 12/4/07

xcopy /s/d/y c:\dir1\*.* d:\dir1

should to the trick... no need for any "fancy stuff"
Steve Knight

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck