Hum. Énervant, ces transformations inopinées du texte. Je réessaye en html
AppleScript :
set myscriptpython to "'/Volumes/macintosh_hd/ChangeLabelColor.py'"
set zecolor to choose from list {"none", "gray", "green", "purple", "blue",
"yellow", "red", "orange"} with prompt "Choisir une couleur"
tell application "Finder" to set filestotag to the selection as alias list
-- ou droplet...
repeat with f in filestotag
set f to quoted form of POSIX path of f
do shell script "python " & myscriptpython & space & f & space & zecolor
end repeat
python à enregistrer dans un fichier .py :
#!/usr/bin/env python
import sys
myfilepath=sys.argv[1]
mycolor=sys.argv[2]
from xattr import xattr
def set_label(filename, color_name):
colors = ['none', 'gray', 'green', 'purple', 'blue', 'yellow', 'red',
'orange']
key = u'com.apple.FinderInfo'
attrs = xattr(filename)
current = attrs.copy().get(key, chr(0)*32)
changed = current[:9] + chr(colors.index(color_name)*2) + current[10:]
attrs.set(key, changed)
set_label(myfilepath, mycolor
Subject: Re: [AS] Changer le label du fichier (tag de couleur)
> Au final, en demandant gentiment au shell de demander à python de tagger
> com.apple.FinderInfo au bon endroit :
>
> AppleScript :
>
> set myscriptpython to "'/Volumes/macintosh_hd/ChangeLabelColor.py'" # le
> chemin du script ci-dessous
> set zecolor to choose from list {"none", "gray", "green", "purple",
> "blue", "yellow", "red", "orange"} with prompt "Choisir une couleur"
> tell application "Finder" to set filestotag to the selection as alias list
> -- ou droplet...
> repeat with f in filestotag do shell script "python " & myscriptpython &
> space & quoted form of POSIX path of f & space & zecolor
> end repeat
>
>
> Python (texte à enregistrer nom_du_script.py) :
>
> #!/usr/bin/env python
>
> import sys
> myfilepath=sys.argv[1]
> mycolor=sys.argv[2]
>
> from xattr import xattr
> def set_label(filename, color_name):
> colors = ['none', 'gray', 'green', 'purple', 'blue', 'yellow', 'red',
> 'orange']
> key = u'com.apple.FinderInfo'
> attrs = xattr(filename)
> current = attrs.copy().get(key, chr(0)*32)
> changed = current[:9] + chr(colors.index(color_name)*2) + current[10:]
> attrs.set(key, changed)
>
> set_label(myfilepath, mycolor)
>
>
>
>>
>
>
> _______________________________________________
> Applescript_fr mailing list
> Applescript_fr@???
> http://listes.patpro.net/mailman/listinfo/applescript_fr
>
_______________________________________________
Applescript_fr mailing list
Applescript_fr@???
http://listes.patpro.net/mailman/listinfo/applescript_fr