Skip to content

Instantly share code, notes, and snippets.

@seandenigris
Created February 5, 2018 03:27
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 seandenigris/8256f709afd6a21e790fe3b5aab79544 to your computer and use it in GitHub Desktop.
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)
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