-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsvverifyfiles.php
More file actions
executable file
·40 lines (31 loc) · 875 Bytes
/
csvverifyfiles.php
File metadata and controls
executable file
·40 lines (31 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* @file
* CSV Generate ID is a tool to generate unique ids per row.
*/
define('KEY_ID', 'id');
define('FILENAME_ID', 'iid');
define('FOLDER', '');
define('FILES_FOLDER', 'photos');
include 'common.php';
// CSV Files. First will be used as base.
$source = FOLDER . 'images.csv';
$output_file_name = FOLDER . 'output.csv';
$header = [];
$data = [];
$missing = [];
// Get the base file.
$csvsource = getCSV($source);
$data = $csvsource['data'];
$header = $csvsource['header'];
foreach ($data as $key => $entry) {
$filename = FILES_FOLDER . '/' . $entry[FILENAME_ID] . '.jpg';
if (!file_exists($filename)) {
$missing[] = [$entry[FILENAME_ID], $entry[FILENAME_ID] . '.jpg'];
}
}
$header = [FILENAME_ID, 'file_name'];
array_unshift($missing, $header);
putCSV($output_file_name, $missing);
print count($missing) - 1 . ' files listed.' . "\n";
exit;