Skip to content

Instantly share code, notes, and snippets.

@ko31
Created October 10, 2019 02:34
Show Gist options
  • Save ko31/be94ad6b94a5024e600302d43ccc8080 to your computer and use it in GitHub Desktop.
Save ko31/be94ad6b94a5024e600302d43ccc8080 to your computer and use it in GitHub Desktop.
YYYY/MM/DD/[filename].html というファイルに対して、ディレクトリ構成の年月日からファイル最終更新日時をセット
<?php
/**
* YYYY/MM/DD/[filename].html というファイルに対して、
* ディレクトリ構成の年月日からファイル最終更新日時をセット
*/
$paths = glob('*/*/*/*.html');
foreach ($paths as $path) {
list($year, $month, $day, $file) = explode('/', $path);
touch($path, strtotime(sprintf('%s/%s/%s', $year, $month, $day)));
echo "Touched {$path}\n";
}
echo "Done\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment