views:

34

answers:

2

I am trying to perform a big checkin of a lot of semi-automatically generated files, and they should all have svn:mime-type properties. I've set a lot using find, but how do I now find all those remaining files that are to be added and which haven't had a MIME type assigned?

+1  A: 

You could do something like this.

Have a script like this:

 #!/bin/sh

 for x do
    mt=`svn propget svn:mime-type $x`
     if [ -z $mt ]; then
        echo "setting mime-type for $x"
        svn propset svn:mime-type MIME_TYPE_HERE $x
    fi
 done

Then you could call it via xargs and find

find . -type f -name "newfile*" -print | xargs my_check_script.sh
seth
I'd probably want echo $x inside that if, but yeah, that seems reasonable.
Michael Norrish
ok, updated my answer a bit.
seth
A: 

Following Seth's basic idea, I did

for x do
  mt=$(svn pg svn:mime-type $x 2> /dev/null)
  if [ -z $mt ]
  then
    echo $x
  fi
done

in the file no-mime-type.sh (made executable etc etc). Then

find . -type f \! -regex '.*\.svn.*' | xargs no-mime-type.sh

There's probably a better way to avoid the .svn directories that are lying around.

Michael Norrish
ah...thanks for `pg`...didn't know about that shortcut.
seth