Skip to content

Instantly share code, notes, and snippets.

@timabell
Created April 16, 2010 18:48
Show Gist options
  • Save timabell/368789 to your computer and use it in GitHub Desktop.
Save timabell/368789 to your computer and use it in GitHub Desktop.
strip non-existent files from monodevelop project file
#!/bin/bash
#strip non-existent files from monodevelop project file
projectFile=$1 #first arg should be the .mdp file to process
if [ "$1" == "" ]
then
echo "usage: $0 project.mdp"
exit 1
fi
#set IFS to allow processing of files with spaces.
#ref http://tldp.org/LDP/abs/html/internalvariables.html
# http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
IFS=$(echo -en "\n\b")
for f in `grep '<File' "$projectFile" | perl -pe 's|.*name="(.*?)".*|\1|'`
do
if [ ! -e "$f" ]
then
echo "'$f' doesn't exist, removing from project..."
escapedFile=`echo $f | sed -e 's/\//\\\\\//g'`
sed -i "/$escapedFile/d" $projectFile
fi
done
echo "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment