0

I have a folder that I'd like to monitor. Whenever there's filenames containing non alphanumeric characters, I'd like to rename them. How could I write a shake rule to express this?

daydaynatation
  • 550
  • 2
  • 8
  • 1
    Why do you want to use Shake for this task? I would have recommended some file-watching program (e.g. Steel Overseer, Watchman). Shake excels at things where you have expensive computations and want to cache them - but file renames are cheap, and once they've happened, there is no incrementality to take advantage of. Shake also makes the assumption that the source files are untouched, which makes things harder. – Neil Mitchell Oct 29 '20 at 11:40
  • @NeilMitchell Thank you this is very helpful hint, about the incrementality and caching. But apart from this, do you think it's possible or trivial to express this rule? I'm just trying to get a feel about writing Shake rules. – daydaynatation Oct 29 '20 at 19:21
  • You'd have to wrap Shake in something like Steel Overseer to get the monitoring. But any rule is fundamentally going to move the old file to a new location, and that modifying of inputs is going to cause you lint failures, because your build system now changes the world. If you wanted to _copy_ them to the non-alphanumeric names that would be more feasible - you'd write a rule that depends on the directory listing. This rule would also recopy all non-alphanum files that changed over the alphanum ones. – Neil Mitchell Oct 30 '20 at 13:45
  • @NeilMitchell Great hint, now I understand what directory listing are meant for! I actually don't care about monitoring. I can run the shake script manually. Thx man! – daydaynatation Oct 30 '20 at 21:52

0 Answers0