Blog

10 May, 2009

Bash script for creating files in empty folders – Mercurial workaround

Posted by: admin In: Programming

I was astonished to find out that Mercurial was unable to represent empty folders. The most obvious workaround is to create an empty file in each of those folders. But hey, you don’t want to do that by hand do you? Well luckily we’re all using a Linux based OS with an extremely powerful command line. It took me just a couple of minutes to come up with a one-liner bash script which creates an empty file in every empty directory.

find . -empty -type d | xargs –replace=EMPTYDIR touch “EMPTYDIR/.empty”

This will put an empty file named “.empty” in every empty sub directory from where you’re standing.

Please make sure that you copy the line correctly. There is an double hyphen before xargs’s replace parameter and regular double quotes around the touch argument.

No Responses to "Bash script for creating files in empty folders – Mercurial workaround"

Comment Form