Walis: Some sort of batch script thing

Ever tried deleting a bazillion of files in one directory and got an “Argument list too long” error?1 Find too slow?2

A long time ago, I wrote a short script that solved these kind of problems. I call it Walis (broom or sweep in Filipino). This script will recursively scan a directory and output the files with your command (and even add output redirection).

To use this script to delete the files, type walis /some/path "rm -f" | sh. To move files in separate directories into one, type walis /some/path "mv " /another/path/ | sh.

The script is very simple. You can modify it to check a file’s timestamp or do some string manipulation (useful for renaming).

I’m too lazy to take a look at bash so this is written in PHP. You just need the command line version of PHP to get this to work.

[Download]

1 We found log files that averaged in 4KB in size. They were dumped in several subdirectories and rm -rf couldn’t do it.
2 Tried find to delete old log files but it was so slow that it would’ve taken 3 months to complete the task. But an application was spitting out logs at a rate so fast, it would fill up the partition in a month.

close Reblog this comment
blog comments powered by Disqus
Locations of visitors to this page
De La Salle Canlubang Top Sites top blogs Best blogs on the Web: all about WWW