How to get files that have been added/modifed in a batch file

Posted by Chris L on Programmers See other posts from Programmers or by Chris L
Published on 2012-09-27T19:27:40Z Indexed on 2012/09/27 21:50 UTC
Read the original article Hit count: 176

Filed under:
|

I have the following batch file which concatenates all of the files in a folder that have a .sql ending.

set func=%~dp0%Stored Procedures\*.sql
for %%i in (%func%) do type "%%i" >>InstallScript.sql

We use SVN as our repository, and we're using branching. Currently the script concatenates all the .sql files, even the ones that haven't changed. I'd like to change it so it only concatenates files that have been modified and/or created after the branch was created. We can do that by looking at the datetime on the .svn folder in each folder(there's a Stored Procedure, View, Function subfolders). But I don't know how to do that with batch files.

Ideally something like this(psuedo code):

set func=%~dp0%Stored Procedures\*.sql
set branchDateTime=GetDateTime(%~dp0%.svn)  <- Gets the datetime when the .svn folder was created

for %%i in (%func%)
{
  if(%%i.LastModifiedOrCreated > branchDateTime)
   do type "%%i" >> InstallScript.sql
}

© Programmers or respective owner

Related posts about svn

Related posts about deployment