Deleting files with applescript messes up Finder’s CoverFlow

applescriptautomatorfinder

I wrote myself a little script to delete JPG+RAW files by just reviewing my JPG (who loads faster thant CR2).

I've put the following code in an Automator service bound to a keyboard shortcut.

on run {input, parameters}
tell application "Finder"
    set myFile to item 1 of input
    set {dispName, nameExt} to the {displayed name, name extension} of myFile
    set extLength to length of nameExt
    set nameWithoutExt to (characters 1 thru ((length of dispName) - extLength) of dispName) -- with the . at the end
    set rawfile to ((parent of myFile as string) & nameWithoutExt & "CR2") as string
    
    set fileIndex to index of myFile
    
    delete every item in {myFile, rawfile}
    
    select file fileIndex of window 1
end tell
end run

It works well but it seems to mess with Finder's cover flow : The pictures are not deleted in the coverflow. As you can see i'm a the bottom of the list and coverflow show more picture than there are in the directory (as multiple deletions reduces the size of the list but not the size of the coverflow).

enter image description here

Any idea why ? Is that maybe a bug in Mavericks ? Or am I missing something ?

Edit : Well I just got the same behavior using Command+<-. Maybe a bug of Finder in Mavericks ?

Best Answer