bbbngowc Posted April 9, 2009 Share Posted April 9, 2009 Hello Good peeps of Mother Earth,Can someone help me with a Windows scripts please? I need a script that will:1. Check a directory for new files2. Copy ONLY new files to another location3. Repeat the processI can do this in UNIX with the -newer command, but I'm unfamiliar with a way to do this in Windows. Does anyone have a script on hand that can do this? I looked at RoboCopy and RichCopy for Windows, but they don't have the flexibilty I'm looking for.I tried using the below commands and it works ... except .... I have another system doing an FTP to get the copied files. Once the system copies the files using ftp, it renames and moves the files. Because of this, when the xcopy command runs again, it recopies all the files. I don't want this.set backupcmd=c:windowssystem32xcopy.exe /c /d /e /h /r /yset dt=%date:~10,4%%date:~4,2%%date:~7,2%%backupcmd% source_dir *%dt%.txt destination_dir Link to comment Share on other sites More sharing options...
Yzöwl Posted April 15, 2009 Share Posted April 15, 2009 Have you thought about date/time stamps? Link to comment Share on other sites More sharing options...
bbbngowc Posted April 20, 2009 Author Share Posted April 20, 2009 What I'm trying to do is:1. Check a directory for all files2. copy all files with *.tada extensions3. modify a file "afterme.txt"When the script runs again it should:1. Check a directory for all files newer than "afterme.txt"2. Copy all new files with the *.tada extension3. modify the "afterme.txt" fileI can do this in unix with the following command "find / -type f -name "*.tada" -newer afterme.txt -exec cp {}......" But I don't know how to duplicate this in windows. Obviously the newer command doesn't exist in windows. XCOPY doesn't offer this kinda of flexibilty, I don't know VB or Perl, but I need something to accomplish this task in windows. Link to comment Share on other sites More sharing options...
bbbngowc Posted April 21, 2009 Author Share Posted April 21, 2009 What I'm trying to do is:1. Check a directory for all files2. copy all files with *.tada extensions3. modify a file "afterme.txt"When the script runs again it should:1. Check a directory for all files newer than "afterme.txt"2. Copy all new files with the *.tada extension3. modify the "afterme.txt" fileI can do this in unix with the following command "find / -type f -name "*.tada" -newer afterme.txt -exec cp {}......" But I don't know how to duplicate this in windows. Obviously the newer command doesn't exist in windows. XCOPY doesn't offer this kinda of flexibilty, I don't know VB or Perl, but I need something to accomplish this task in windows.Someone just reminded me of Cygwin. Since I can do what I need in UNIX, Cygwin is the answer! Link to comment Share on other sites More sharing options...
SenHu Posted May 23, 2009 Share Posted May 23, 2009 The original poster wants to1. Check a directory (assuming C:/dir1) for all files2. copy all files with *.tada extensions (assuming to C:/dir2)3. modify a file "afterme.txt" (assuming also in C:/dir2)Here is a script in biterscripting (http://www.biterscripting.com/install.html) . Will work on all windows versions.# Get the modification time stamp of file C:/dir2/afterme.txt.var str timestamp; af "C:/dir2/afterme.txt" if ($fexists) set $timestamp = $fmtime;endif# If afterme.txt does not exist, then $timestamp will remain empty.# Get a list of *.tada files in directory C:/dir1 which were modified after $timestamp.var str filelist; lf -n "*.tada" "C:/dir1" ($fmtime >= $timestamp) > $filelist# Copy files one by one.while ($filelist <> "")do var str file; lex "1" $filelist > $file system copy ("\""+$file+"\"") "C:/dir2"done# Modify the modification timestamp for the afterme.txt file.echo > "C:/dir2/afterme.txt" # We are done !Sen Link to comment Share on other sites More sharing options...
jaclaz Posted May 23, 2009 Share Posted May 23, 2009 Here is a script in biterscripting (http://www.biterscripting.com/install.html) . Will work on all windows versions.Still, you didn't reply/comment on the other thread :http://www.msfn.org/board/index.php?showto...131969&st=5Are you somehow connected to the site/company?Can you share some info on the program?jaclaz Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now