Created
May 7, 2018 06:18
-
-
Save errogaht/456b4248ef17e5a2e287631180dd7e95 to your computer and use it in GitHub Desktop.
evernote shots iOS rename
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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