Search code examples
powershellsvntortoisesvn

SVN last write time of a file in SVN using powershell


I know I can use svn list -v "SVN:URL/file.txt" to get a details of file. I'm looking to get the last modified time of the file and pipe to a variable where i can use further with powershell code.

svn list -v "SVN:URL/file.txt"

Solution

  • Following my first comment, you can adjust the Linux command to match the Powershell's syntax :

    $yourvariable = svn info "SVN:URL/file.txt" | Select-String '^Text Last Updated:' | %{$_ -replace "Text Last Updated: "}
    

    A few comments about this :

    • Select-String is the equivalent of grep. It will return the matching line corresponding to the pattern you are looking for.
    • %{} is an alias of a loop on the previous pipeline output (our line from Select-String). It is here because expressions like "blabla -replace 'bla' " are not allowed into associated pipelines (after | ), so we need to wrap it into something. Obviously, it is a single-pass loop.

    If you want to retrieve another data, just modify the strings in the command (Text Last Updated, Path, Name, Last Changed Author, etc...).