2010-06-24 8 views
0

Si j'ai une liste d'alias, comment puis-je supprimer ceux qui ne sont pas des fichiers normaux ou créer une nouvelle liste avec seulement des fichiers normaux. La question principale est comment déterminer si un alias est un fichier régulier. J'ai essayé ceci, mais c'est hacky et cela ne fonctionne pas toujours (comme avec les fichiers .app).Récupérer uniquement les fichiers normaux d'une liste d'alias dans AppleScript

if (theFile as string) does not end with ":" then ... 

Comment est-ce que je peux faire ceci?

Répondre

1

Vous pouvez utiliser la propriété « type » d'un fichier pour déterminer ce qu'il est ...

set theFile to choose file 
tell application "System Events" 
    set theKind to kind of theFile 
end tell 

if theKind is not "Application" then 
    return "Not an application" 
else 
    return "Is an application" 
end if 
0

Il semble un peu hacky, mais cela semble bien fonctionner:

tell application "Finder" 
    set regularFiles to {} 
    repeat with theFile in theFiles 
     if the URL of theFile does not end with "/" 
      set end of regularFiles to theFile 
     end if 
    end repeat 
end tell 

J'ai d'abord essayé de tester le chemin pour un ":" à la fin, mais il casse pour les applications groupées et les fichiers similaires-qui-sont-vraiment-dossiers.

Questions connexes