Home > Uncategorized > Fun with powershell: Copy modified subversion files

Fun with powershell: Copy modified subversion files

Sometimes it is nice beeing able to simply copy all the modified files to a backup directory when working with a larger changeset (even though diff/patch files does more or less the same thing I think this can be nice simply because the files are not crunched and packed into one single chunk). I wrote this little powershell script as an exercise:

# usage: copy-modified.ps1 c:\mysvnprj c:\backup
param([string]$source, [string]$target)

push-location $source

[xml]$x = svn st –xml
$files =$x.status.target.entry | select -expandproperty path | ? { test-path $_ -pathtype leaf }
foreach($fn in $files)
{
    $d = split-path $fn
    $f = split-path $fn -leaf
    $td = join-path $target $d
    if (!(test-path $td))
    {
       md $td | out-null
    }
    copy $fn $td
}

pop-location

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: