I got sick of deleting all my .bak files manually when I was done with a project, so I wrote a quick php script to do a batch job. I added an menu option for right click on folders. probably could be cleaner, but thought I share with the forum for anyone else who might be interested.
requirements:
* Windows
* php installed
* a bunch of unwanted .bak files
installation:
1) copy this script to a file and save it somewhere useful (referenced as C:/path/to/cleanBakFiles.php) - don't forget to wrap it in <?php ?>.
2) open an explorer window and go to Tools > Folder Options
3) on the File Types tab, select Folder and click Advanced
4) click New...
Action: Clean .bak Files
Application used to perform action: C:\path\to\php.exe C:/path/to/cleanBakFiles.php "%1"
5) try it out.
Hope this helps someone out. There is a way to set the right click action with regedit, post if you need a hand with that.
requirements:
* Windows
* php installed
* a bunch of unwanted .bak files
installation:
1) copy this script to a file and save it somewhere useful (referenced as C:/path/to/cleanBakFiles.php) - don't forget to wrap it in <?php ?>.
Code: Select all
if($argc != 2){
echo "no dice - need a folder name";
}
else{
f_delete_bak_files($argv[1]);
}
function f_delete_bak_files($dir){
if(is_dir($dir)){
if($dh = opendir($dir)){
while(($file = readdir($dh)) !== false) {
if(is_dir($dir ."/". $file) && $file != "." && $file != ".."){
f_delete_bak_files($dir ."/" . $file);
}
if(ereg(".bak$", $file) || ereg(".BAK$", $file)){
unlink($dir . "/" . $file);
echo("DEL - " . $dir . "/" . $file . "\n");
}
}
return true;
}
}
else{
return false;
}
}
3) on the File Types tab, select Folder and click Advanced
4) click New...
Action: Clean .bak Files
Application used to perform action: C:\path\to\php.exe C:/path/to/cleanBakFiles.php "%1"
5) try it out.
Hope this helps someone out. There is a way to set the right click action with regedit, post if you need a hand with that.