Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get files that have been added/modifed in a batch file
    primarykey
    data
    text
    <p>I have the following batch file which concatenates all of the files in a folder that have a .sql ending.</p> <pre><code>set func=%~dp0%Stored Procedures\*.sql for %%i in (%func%) do type "%%i" &gt;&gt;InstallScript.sql </code></pre> <p>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.</p> <p>Ideally something like this(pseudo code):</p> <pre><code>set func=%~dp0%Stored Procedures\*.sql set branchDateTime=GetDateTime(%~dp0%.svn) &lt;- Gets the datetime when the .svn folder was created for %%i in (%func%) { if(%%i.LastModifiedOrCreated &gt; branchDateTime) do type "%%i" &gt;&gt; InstallScript.sql } </code></pre> <p>Thanks to Doc Brown, I ended up getting this(for anyone that needs something similar):</p> <pre><code>@echo off cls echo --Install Script Generated For MMH Database %DATE% %TIME% &gt; InstallScript.sql set branch=%~dp0.svn for %%i in (%branch%) do set SvnFileDate=%%~ti set year=%SvnFileDate:~8,2% set month=%SvnFileDate:~0,2% set day=%SvnFileDate:~3,2% set hours=%SvnFileDate:~11,2% set minutes=%SvnFileDate:~14,2% set datetime=%year%%month%%day%%hours%%minutes% :: Folder for Functions set func=%~dp0%Functions\*.sql setlocal enableextensions enabledelayedexpansion @for %%i in (%func%) do set FuncFileDate=%%~ti&amp; ^ set year2=!FuncFileDate:~8,2!&amp; ^ set month2=!FuncFileDate:~0,2!&amp; ^ set day2=!FuncFileDate:~3,2!&amp; ^ set hours2=!FuncFileDate:~11,2!&amp; ^ set minutes2=!FuncFileDate:~14,2!&amp; ^ set datetime2=!year2!!month2!!day2!!hours2!!minutes2!&amp; ^ if "!datetime!" LSS "!datetime2!" type "%%i" &gt;&gt; InstallScript.sql :: I would add similiar code for each folder, one for Views, Stored Procs, etc... endlocal pause </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload