开发者

How can I mass-convert images saved as text/ascii in svn to binary?

Somehow images got saved as text/ascii and I need to recursively do this for hundreds of directories of images, all under one root images directory.

I got some instructions here which tell me to:

svn proplist <you开发者_开发知识库rfile>
svn propdel svn:eol-style <yourfile>
svn propset svn:mime-type application/octet-stream <yourfile>

Is there some native svn recursive way I can do this? If not, could someone advise how I could recursively apply this with a bash script?


On the shell:

find -name '*.png' -exec \
sh -c "svn propdel svn:eol-style {} && svn propset svn:mime-type image/png {}" \;


I don't have a Subversion repository where I can test this out, but it shouldn't be too difficult:

find . -name .svn -prune -o print

This will list all of the files in your working directory (sans the .svn directories).

Now, you can combine this with a while read loop

find . -name .svn -prune -o print | while read file
do
   svn propdel svn:eol-style $file
   svn propset svn:mime-type application/octet-stream $file
done

Now, you notice I'm not verifying whether or not the files have that property set or not. I simply don't care. And, this will do every file. If you want only to do a particular type of file, you'll have to modify the find command:

find . -name .svn -prune -o -name "*.jpg" print

I highly suggest you start with a clean Subversion working directory, and run a test like this:

find . -name .svn -prune -o print | while read file
do
   echo svn propdel svn:eol-style $file
   echo svn propset svn:mime-type application/octet-stream $file
done

If the output of that looks good, then remove the echo and let 'er rip.


The following powershell code will achieve what you're looking to do:

foreach( $file in get-childitem -name -include *.png -exclude .svn -recurse) {
    &  svn propdel svn:eol-style $file;
    & svn propset svn:mime-type image/png $file
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜