Add new galleries and posts, update photos in other gallery
This commit is contained in:
25
_scripts/copy-photos.php
Normal file
25
_scripts/copy-photos.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require __DIR__ . '/utilities.php';
|
||||
|
||||
$sGallery = '2016-conic-hill';
|
||||
$sSourceDir = 'D:\Rik\Photographs\Schotland\Activiteiten\Hike\Conic Hill';
|
||||
$sFile = sprintf('%s/../_data/gallery/%s.yml', __DIR__, $sGallery);
|
||||
yamlParse($sFile, $aYaml, $sContents);
|
||||
$sTargetDir = 'C:\Users\Rik\Downloads\tmp';
|
||||
|
||||
if (!is_dir($sTargetDir)) {
|
||||
mkdir($sTargetDir, 0777, true);
|
||||
}
|
||||
|
||||
$aPhotos = array_map(function($aPhoto) {
|
||||
return $aPhoto['file'];
|
||||
}, $aYaml['photos']);
|
||||
|
||||
foreach ($aPhotos as $sFile) {
|
||||
$sPath = sprintf('%s/%s.jpg', $sSourceDir, $sFile);
|
||||
if (!file_exists($sPath)) {
|
||||
printf("File not found: %s\n", $sFile);
|
||||
}
|
||||
$sTarget = sprintf('%s/%s.jpg', $sTargetDir, $sFile);
|
||||
copy($sPath, $sTarget);
|
||||
}
|
||||
Reference in New Issue
Block a user