Skip to content

Instantly share code, notes, and snippets.

@errogaht
Created May 7, 2018 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save errogaht/456b4248ef17e5a2e287631180dd7e95 to your computer and use it in GitHub Desktop.
Save errogaht/456b4248ef17e5a2e287631180dd7e95 to your computer and use it in GitHub Desktop.
evernote shots iOS rename
<?php
/// renames iOS Evernote files names from Evernote Snapshot 20180502 203934.png ; Evernote Snapshot 20180502 203934 [2].png
/// to android filename style: img_20180502_203934.1.png, img_20180502_203934.2.png
$a = [];
foreach (glob('*.png') as $path) {
preg_match('/(Evernote Snapshot )(\d+) (\d+)\s?(\[\d+\])?/', $path, $matches);
$suffix = $matches[4] ?? null;
$suffix = $suffix ? (int)trim($suffix, '[]') : 1;
$newName = "img_{$matches[2]}_{$matches[3]}.$suffix.png";
rename($path, $newName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment