Import and sort photos from my rx100 SD
0
rx100.ts
35 lines 1.4 kB view raw
1// Import and sort photos from my rx100. 2// Bonus: Query for additional exif data if missing 3import { copy, ensureDir, exists } from "jsr:@std/fs" 4import { join, resolve } from "jsr:@std/path"; 5 6const RX100_PATH = "/Volumes/untitled"; 7const PHOTO_PATH = join(RX100_PATH, "DCIM"); 8const VID_PATH = join(RX100_PATH, "private", "M4ROOT", "CLIP"); 9const DESKTOP = join(Deno.env.get("HOME"), "Desktop"); 10 11for await (const dirEntry of Deno.readDir(PHOTO_PATH)) { 12 if (dirEntry.isDirectory) { 13 const [_, yearText, month, day] = dirEntry.name.match(/^(....)(..)(..)/); 14 const yearName = String(2023); 15 const monthName = [yearName, month].join("_"); 16 const dayName = [yearName, month, day].join("_"); 17 const prevLocation = join(PHOTO_PATH, dirEntry.name); 18 const nextContainer = join(DESKTOP, "photos", monthName); 19 const nextLocation = join(nextContainer, dayName); 20 if (await exists(nextLocation)) continue; 21 await ensureDir(nextContainer); 22 await copy(prevLocation, nextLocation); 23 } 24} 25 26for await (const dirEntry of Deno.readDir(VID_PATH)) { 27 const prevLocation = join(VID_PATH, dirEntry.name); 28 const nextContainer = join(DESKTOP, "videos"); 29 const nextLocation = join(nextContainer, dirEntry.name.toLowerCase()); 30 if (await exists(nextLocation)) continue; 31 await ensureDir(nextContainer); 32 if (/mp4|xml/i.test(dirEntry.name)) { 33 await copy(prevLocation, nextLocation); 34 } 35}