Image sets: a counter in the name ends the set; copy markers, resolutions, _00 go
Each image was a release of its own in: "Set 008 10of63 new0464.jpg", "202/430 princess-079-058.jpg", "( 098 /500) 002 148.jpg" (the counter is part of the name: the set is the text before it), "sexypattycake_0903040445[1].jpg" (a copy's marker), "092_081_2000x1500.jpg" (a resolution) and "KP0027_197_00.jpg" (a constant suffix). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e72a9b1ef5
commit
108d798d97
3 files changed
+35
-4
No files matched your search
+10
-2
@@ -146,13 +146,21 @@ const DATES = /\b(?:(?:19|20)\d{2}[-._ ](?:0?[1-9]|1[0-2])[-._ ]\d{1,2}|\d{1,2}[
|
||||
* "stp250x", "cutie-071-032" → "cutie-071-"); empty for a name without numbers. Suffixes after it that don't
|
||||
* count the images go first: a repeat of the number before (katelg010_10), a year (hgrscans1097_2009), a
|
||||
* size of 4+ digits (…_24of40_1600), and an "of" total (24of40) (LOG.md 2026-10-12 (3)); also a renumbering
|
||||
* right after it (kate108lg029_28) and a camera's timestamp (kurozo-2006-7-26-15-21) (LOG.md 2026-10-12 (5)).
|
||||
* right after it (kate108lg029_28) and a camera's timestamp (kurozo-2006-7-26-15-21) (LOG.md 2026-10-12 (5)); a
|
||||
* counter in the name ends the set, and copy markers, resolutions and "_00" go first (LOG.md 2026-10-12 (6)).
|
||||
*/
|
||||
const TIMESTAMP = /[-_. ]?(?:19|20)\d{2}[-._ ](?:0?[1-9]|1[0-2])[-._ ]\d{1,2}(?:[-._ ]\d{1,2})*$/
|
||||
|
||||
export function imageSet(stem: string): string {
|
||||
// Suffixes that number no image: a copy's ("sexypattycake_0903040445[1]"), a resolution ("092_081_2000x1500"),
|
||||
// a constant one ("KP0027_197_00").
|
||||
const plain = stem.replace(/\s*[[(]\d+[\])]$/, '').replace(/[_-]\d{3,4}x\d{3,4}$/i, '').replace(/[_-]0+$/, '')
|
||||
// A counter in the name counts the images: the set is the text before it ("Set 008 10of63 new0464",
|
||||
// "202/430 princess-079-058", "( 098 /500) 002 148"; each image was a release of its own).
|
||||
const counted = /(\d+)\s*of\s*\d+|[[(]?\s*\d+\s*\/\s*\d+\s*[\])]?/i.exec(plain)
|
||||
if (counted) return plain.slice(0, counted.index)
|
||||
// A camera's timestamp ("kurozo-2006-7-26-15-21"): the date and the time after it number no set.
|
||||
let s = stem.replace(/(\d+)\s*of\s*\d+/gi, '$1').replace(TIMESTAMP, '')
|
||||
let s = plain.replace(TIMESTAMP, '')
|
||||
while (true) {
|
||||
const m = /[_-](\d+)$/.exec(s)
|
||||
if (!m) break
|
||||
|
||||
Reference in new issue
Block a user