IPB

Bienvenue invité ( Connexion | Inscription )

 
Reply to this topicStart new topic
> [RÉSOLU] Créer un fichier de type Adresse Internet du Web (.webloc)
Options
clarusad
posté 22 Feb 2024, 15:50
Message #1


Macbidouilleur de bronze !
**

Groupe : Membres
Messages : 309
Inscrit : 17 Oct 2006
Lieu : Strasbourg, France
Membre no 70 694



Salut,
J'arrive à créer un fichier et écrire dedans mais ça ne fonctionne pas correctement. Seul Safari peut ouvrir ce type de fichier.
Qu'est-ce qui cloche dans le code suivant ?
Merci

Code
tell application "Finder"

    set myNAME to "apple"
    set myURL to "http://www.apple.com"
    
    set the myFILE to ((path to downloads folder) as text) & myNAME
    
    make new file at ((path to downloads folder)) with properties {name:myNAME, file type:"ilht", creator type:"MACS"}
    
    open for access file the myFILE with write permission
    write (myURL) to file the myFILE starting at eof
    close access file the myFILE
        
end tell


Ce message a été modifié par clarusad - 22 Feb 2024, 18:21.
Go to the top of the page
 
+Quote Post
clarusad
posté 22 Feb 2024, 18:20
Message #2


Macbidouilleur de bronze !
**

Groupe : Membres
Messages : 309
Inscrit : 17 Oct 2006
Lieu : Strasbourg, France
Membre no 70 694



Pour que ça fonctionne, il faut déjà ajouter l'extension .webloc au nom de fichier ; ensuite il semble qu'il faille écrire { URL = "https://www.apple.com"; } à l'intérieur du fichier. Voilà le code final :
Code
tell application "Finder"
    
    set myNAME to "apple.webloc"
    set myTEXT to "{ URL = " & quote & "http://www.apple.com" & quote & "; }"
    set the myFILE to ((path to downloads folder) as text) & myNAME
    
    make new file at ((path to downloads folder)) with properties {name:myNAME, file type:"ilht", creator type:"MACS"}
    
    open for access file the myFILE with write permission
    write (myTEXT) to file the myFILE starting at eof
    close access file the myFILE
    
end tell


Ce message a été modifié par clarusad - 22 Feb 2024, 19:03.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



Nous sommes le : 27th April 2024 - 18:20