photonbuddy Posted 5 hours ago Posted 5 hours ago Hi All, I asked ChatGTP to write me an AutoIT script to add a comment, star rating, and tag list to a file. It offered-up the following code: expandcollapse popup#include <Array.au3> ; === CONFIGURATION === Local $sFile = "E:\Downloads\Test.jpg" ; File path Local $sComment = "A Picture" ; Explorer comment Local $iStars = 4 ; Rating (1-5 stars) Local $sTags = "Landscape,Hi-Res,Australia" ; Tags (comma-separated) ; === VALIDATE FILE === If Not FileExists($sFile) Then MsgBox(16, "Error", "File not found: " & $sFile) Exit EndIf ; === PREPARE SHELL OBJECT === Local $oShell = ObjCreate("Shell.Application") If Not IsObj($oShell) Then MsgBox(16, "Error", "Failed to create Shell object.") Exit EndIf ; Get folder and file object Local $sFolderPath = StringLeft($sFile, StringInStr($sFile, "\", 0, -1) - 1) Local $sFileName = StringTrimLeft($sFile, StringInStr($sFile, "\", 0, -1)) Local $oFolder = $oShell.Namespace($sFolderPath) Local $oFile = $oFolder.ParseName($sFileName) If Not IsObj($oFile) Then MsgBox(16, "Error", "Cannot access file properties.") Exit EndIf ; === APPLY PROPERTIES === ; Set Comment $oFile.ExtendedProperty("System.Comment") = $sComment ; Set Rating (convert 1-5 stars to 1-99 scale) If $iStars < 1 Then $iStars = 1 If $iStars > 5 Then $iStars = 5 Local $iRatingValue = ($iStars * 20) - 1 ; Example: 4 stars = 79 $oFile.ExtendedProperty("System.Rating") = $iRatingValue ; Set Tags (comma-separated) $oFile.ExtendedProperty("System.Keywords") = $sTags ; === VERIFY === Local $iCommentIndex = -1, $iRatingIndex = -1, $iTagIndex = -1 For $i = 0 To 266 Switch $oFolder.GetDetailsOf($oFolder.Items, $i) Case "Comments" $iCommentIndex = $i Case "Rating" $iRatingIndex = $i Case "Tags" $iTagIndex = $i EndSwitch Next Local $sOut = "" If $iCommentIndex <> -1 Then $sOut &= "Comment: " & $oFolder.GetDetailsOf($oFile, $iCommentIndex) & @CRLF If $iRatingIndex <> -1 Then $sOut &= "Rating: " & $oFolder.GetDetailsOf($oFile, $iRatingIndex) & @CRLF If $iTagIndex <> -1 Then $sOut &= "Tags: " & $oFolder.GetDetailsOf($oFile, $iTagIndex) & @CRLF MsgBox(64, "Result", $sOut) It doesn't work 😞 It doesn't spit out any errors, however, the VERIFY code works, and spits out the correct information as set through Explorers property window. I'm keen to understand why it doesn't work, and if there is a way to correct it. Thanks for any insights offered.
bogQ Posted 1 hour ago Posted 1 hour ago (edited) W8, you rly just asked chatgpt for script and now when its not working your asking us for help instead of posting your script to the one that suggested it? Guess what, when i did that i got response to a problem. I did not ask question, i did not request answer, just copy paste... So next time if he writes you a script, i would suggest asking him for help instead of others. Not gonna post about his answer, copy paste it there your self there and see for your self. For me (and I presume for allot of other forum users), there is some threshold that requires post requesters to @ least show some initiative before involvement. I do not think chatgpt showed your initiative. Edited 1 hour ago by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now