Created
February 5, 2018 03:27
-
-
Save seandenigris/8256f709afd6a21e790fe3b5aab79544 to your computer and use it in GitHub Desktop.
Scratch pad of code to verify some photos were moved successfully (works in Pharo)
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
dropBox := (FileLocator home / 'Dropbox/source_folder'). | |
dbFiles := dropBox allFiles reject: [ :e | e basename = '.DS_Store' ]. | |
targetFolder := '/path/to/target' asFileReference. | |
targetFiles := targetFolder allFiles reject: [ :e | e basename = '.DS_Store' ]. | |
[ :job | | |
(targetFiles last: (targetFiles size - 1369)) do: [ :tf | | |
| suffix matches | | |
suffix := tf basename copyAfterLast: $_. | |
matches := dbFiles select: [ :sf | | |
| currentSuffix | | |
currentSuffix := (tf base copyAfterLast: $_) asNumber < 1000 | |
ifFalse: [ sf basename copyAfterLast: $_ ] | |
ifTrue: [ sf basename copyAfterLast: $ ]. | |
currentSuffix = suffix ]. | |
self assert: matches size = 1. | |
(tf isMD5Equal: matches first) ifFalse: [ self error: 'file changed!' ]. | |
job increment ] ] asJob | |
max: targetFiles size; | |
run. | |
"Experiment to isolate problemically-named files" | |
problemIndices := OrderedCollection new. | |
dbFiles doWithIndex: [ :e :i | | |
(e basename copyAfterLast: $_) = '' ifTrue: [ problemIndices add: i ] ]. | |
dbFiles detectIndex: [ :e | (e basename copyAfterLast: $_) = '351.JPG' ]. | |
problemIndices collect: [ :i | (dbFiles at: i) basename copyAfterLast: $ ]. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment