Posted By

bartbons on 03/20/07


Tagged

svn delete remove files missing


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

jarjar2k7
koncept
radarseven
mrtambourineman


remove missing files with SVN


 / Published in: SVN
 

URL: http://svn.haxx.se/users/archive-2005-07/0849.shtml

  1. svn rm $( svn status | sed -e '/^!/!d' -e 's/^!//' )

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: troy on January 29, 2009

Hello, I like the Unix script above, but at work I'm forced into a Windows environment. For others stuck in a Windows environment, I hope the following will be useful. (I'm not experienced with Windows batch scripting, but the following worked for me on Windows XP.)

@echo off :: This script deletes files from svn that are missing in the specified working copy.

if "%1"=="" ( echo usage: %0 workingCopy exit /b )

for /f "usebackq tokens=1*" %%a in (svn status %1) do ( if "%%a"=="!" ( echo svn delete "%%b" svn delete "%%b" )
)

Posted By: troy on January 29, 2009

Hello, I like the Unix script above, but at work I'm forced into a Windows environment. For others stuck in a Windows environment, I hope the following will be useful. (I'm not experienced with Windows batch scripting, but the following worked for me on Windows XP.)

@echo off :: This script deletes files from svn that are missing in the specified working copy.

if "%1"=="" ( echo usage: %0 workingCopy exit /b )

for /f "usebackq tokens=1*" %%a in (svn status %1) do ( if "%%a"=="!" ( echo svn delete "%%b" svn delete "%%b" )
)

Posted By: troy on January 29, 2009

A couple newline characters got lost when posting. Not sure how to fix, but you get the idea. Sorry for the repost.

Posted By: troy on January 29, 2009
@echo off
:: This script deletes files from svn that are missing in the specified working copy.

if "%1"=="" (
  echo usage: %0 workingCopy
  exit /b
)

for /f "usebackq tokens=1*" %%a in (`svn status %1`) do (
  if "%%a"=="!" (
    echo svn delete "%%b"
    svn delete "%%b"
  )  
)
Posted By: craiga on March 13, 2009

Doesn't work with file paths with whitespace.

Posted By: grabur on July 7, 2009

How about something convulted like this?

svn status | sed -e '/^!/!d' -e 's/^! *//' | tr '\n' '\0' | xargs --null -i -t svn rm {}

Posted By: acdvorak on September 17, 2010

This snippet removes all missing files, including those that have spaces in their paths:

svn status | sed -Ee '/^!/!d' -e 's/^! *(.*)/"\1"/g' | xargs -L1 svn rm
Posted By: mrtambourineman on November 4, 2010

cheers dude this works a treat! proper bo

Posted By: bhushan154 on April 18, 2013

This command is not working anymore on windows xp. Can anyone help me out with this?

svn status E:\balaji\checkout | sed -e '/^!/!d' -e 's/^! *//' | tr '\n' '\0' | xargs --null -i -t svn rm {}

Posted By: bhushan154 on April 18, 2013

I am using subversion 1.7.7 and I get an error

sed is not recognised as an internal or external command, operable program or batch file.

svn status E:\balaji\checkout | sed -e '/^!/!d' -e 's/^! *//' | tr '\n' '\0' | xargs --null -i -t svn rm {}

You need to login to post a comment.