Bonsoir,
je travaille sur un applescript qui servira à créer un utilisateur qui aura le même nom que le mac. Le nom des ordinateurs sur lesquels je vais utiliser ce script ont une majuscule sur le 1er caractère. Pour créer l'utilisateur, il faut avoir en + du nom de l'ordi tel quel, ce même nom en minuscule.
J'ai donc trouvé ce code sur un site:
Ce code fonctionne super bien sauf jusqu'à la dernière étape. J'ai placé des display dialog tout du long pour vérifier la bonne exécution de chaque étape.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 set nomDuMac to "Lilou" set nomDuMacMinuscule to nomDuMac --display dialog nomDuMacMinuscule & " " & nomDuMac renommer(nomDuMacMinuscule) display dialog nomDuMacMinuscule & " " & nomDuMac on renommer(texte) set leNB to count of word of texte set leChar to first character of texte set leNum to ASCII number of leChar -- display dialog leChar & leNum if leNum < 91 and leNum > 64 then set leNum to leNum + 32 -- display dialog leNum set NewChar to (ASCII character leNum) set NBChar to count of character of texte set LeMotFinal to NewChar & text 2 thru NBChar of texte -- display dialog NewChar & NBChar & LeMotFinal searchReplaceText(texte, LeMotFinal, texte) set texte to result -- display dialog texte end if display dialog texte return texte end renommer on searchReplaceText(searchTerm, replaceTerm, theText) set oldTID to AppleScript's text item delimiters set AppleScript's text item delimiters to searchTerm set theText to theText's text items set AppleScript's text item delimiters to replaceTerm set theText to theText as text set AppleScript's text item delimiters to oldTID -- display dialog theText return theText end searchReplaceText
Mais j'ai l'impression que renommer n'arrive pas à retourner texte comme il devrait.
Merci à celui qui saura me dire ce que j'ai oublié.
Bonne soirée.
Partager