Created
August 22, 2020 05:39
-
-
Save braytac/626c42596eac7ef46295cf3a2b35cdfc to your computer and use it in GitHub Desktop.
gen txt list for montpres pdf.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function human_filesize($bytes, $decimals = 1) { | |
$sz = 'BKMGTP'; | |
$factor = floor((strlen($bytes) - 1) / 3); | |
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor]; | |
} | |
$folder = "/home/webs/montpres/wp-content/uploads/molt_psp_familias_completas"; | |
$genlist = "/home/webs/montpres/wp-content/pdf_generados.txt"; | |
$listado = array(); | |
$iterator = new DirectoryIterator( $folder ); | |
foreach ($iterator as $fileinfo) { | |
if ( strtolower($fileinfo->getExtension()) == "pdf") { | |
$dat = date("Y-m-d H:i", $fileinfo->getMTime()); | |
$size = human_filesize( $fileinfo->getSize()); | |
$listado[$dat] = "1 ".$size." ".$dat." ".$fileinfo->getFilename()."\n" ; | |
} | |
} | |
ksort($listado); | |
$listado = array_reverse($listado); | |
file_put_contents($genlist, implode($listado)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Antes con bash:
#!/bin/bash
echo "Generando Listado...";
ls -laGght --time-style=long-iso
/home/webs/montpres/wp-content/uploads/molt_psp_familias_completas
| sed -re 's/^[^ ]* //'
| grep ".pdf" --color=never \