-1

I have a folder 'script'. People check-in the files to this folder. Every time they check-in, I need to get the those files alone and execute them. For that, current timestamp needs to be saved in some log file. so that we can get the files that are modified after the last build by comparing the current time with last execution time(which is saved in log file). Let me explain that clearly.

Folder name -- script.
there three files in this folder -- a.sql, b.sql, c.sql


after few hours -- two new files are created. also b.sql is modified. totally five files -- a.sql, b.sql, c.sql, d.sql, e.sql


now I need to execute only those two new files and one modified file.
it should be like below
b.sql
d.sql
e.sql


we need to compare the current time with last execution time and get the files that are modified/created between two timestamps.

Can someone tell me how to do it using vbscript or windows script?

Ansgar Wiechers
  • 175,025
  • 22
  • 204
  • 278
Ela
  • 257
  • 1
  • 4
  • 16
  • SO is not a place where other people write code for you. What have you tried so far, and what specific part of your code are you having trouble with? – Ansgar Wiechers Dec 09 '14 at 18:54
  • 2
    I'd try to get away with using the archive attribute for the record keeping. Then it's just: for each file with archive set: execute and clear that attribute. – Ekkehard.Horner Dec 09 '14 at 19:14
  • @AnsgarWiechers the folder will have db scripts. those have to be applied to databases. the people check-in the files to repository(Git). will get the files from there. Thank you.. – Ela Dec 10 '14 at 04:43
  • @Ekkehard.Horner I don't understand..Could you explain me how it works? Thanks bunch.. – Ela Dec 10 '14 at 04:45
  • Again, SO is not a place where you post your requirements and other people write code for you. Show the code you have written so far, and explain what part of it doesn't work as expected. – Ansgar Wiechers Dec 10 '14 at 08:59
  • I just wanted to get the scripts from folder and run them. I am a dev-ops person who does the deployment setup. For example, I get the files from folder at 2 pm. after that, there are some changes. Again i am asked to get the files and run them at 5 pm. now I just need the files that are modified\created in that folder after 2 pm.(between 2pm - 5pm). Thanks a ton for your response :) – Ela Dec 10 '14 at 17:48

1 Answers1

0

Look at the docs and this demo code:

Option Explicit

Const Archive = 32

Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject")
Dim oFile
For Each oFile In goFS.GetFolder("..\data").Files
    WScript.Echo oFile.Name, oFile.Attributes
    If oFile.Attributes And Archive Then
       WScript.Echo oFile.Name, "execute and clear archive bit"
       oFile.Attributes = oFile.Attributes - Archive
    End If
Next
Ekkehard.Horner
  • 37,203
  • 2
  • 36
  • 83