2016-09-23 1 views
1

J'ai besoin d'un script qui regarde le chemin de la fenêtre active du finder et vérifie si le pahth contient un nom. Si un certain nom est trouvé, alors une autre variable devrait être changée en quelque chose d'autre.Applescript: vérifie si le chemin de la fenêtre finder active contient un certain nom pour changer un var.

tell application "Finder" ensemble currentDirectory pour cibler la fenêtre Finder 1 end tell ensemble maVar à "quelque chose" ensemble MyVar2 à "xxx"

si currentDirectory contient maVar puis mis MyVar2 à « autre chose "

Répondre

0

S'il vous plaît essayer ce code et laissez-moi savoir si cela fonctionne pour vous:

set myVar1 to "Users" 
set myVar2 to "2" 
set myVar3 to "3" 

tell application "Finder" 
    set thePath to (POSIX path of (target of window 1 as alias)) 
    if thePath contains myVar1 then 
     set myVar2 to myVar3 
    end if 
end tell