1
0
mirror of https://github.com/captn3m0/Scripts.git synced 2024-09-20 15:57:23 +00:00
scripts/calibre_cleanup.php
2012-01-28 12:44:33 +05:30

23 lines
542 B
PHP
Executable File

#!/usr/bin/php
<?php
$directory = '/home/nemo/.gvfs/Nemo%27s iPad/Books/Purchases/';
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
while($it->valid()){
if (!$it->isDot()){
$filename = $it->key();
if(substr($filename,-6)=='.xhtml'){
echo $filename."\n";
$f = file($filename);
if(count($f)>10){
if(strpos($f[10],"@namespace")!==false){
$f[10]="<div>\n";
$contents = join("",$f);
file_put_contents($filename,$contents);
echo "Updated\n";
}
}
}
}
$it->next();
}