Estoy tratando de escribir un AppleScript para realizar operaciones de búsqueda y reemplazo en forma masiva en los nombres de las pistas de iTunes. Actualmente, este es mi código:
tell application "iTunes" set sel to selection of front browser window if sel is {} then try display dialog "Nothing is selected…" buttons {"Quit"} with icon 0 end try return end if set c to (count of sel) set theSearchString to display dialog "Find:" default answer "" --prompt for input to search for set theReplacementString to display dialog "Replace with:" default answer "" --prompt for input to search for repeat with i from 1 to c --set the movement numbers set thisTrack to item i of sel set songName to (get name of thisTrack) set name of thisTrack to (findAndReplaceInText(songName, text returned of theSearchString, text returned of theReplacementString)) end repeat end tell on findAndReplaceInText(theText, theSearchString, theReplacementString) set AppleScript's text item delimiters to theSearchString set theTextItems to every text item of theText set AppleScript's text item delimiters to theReplacementString set theText to theTextItems as string set AppleScript's text item delimiters to "" return theText end findAndReplaceInText
Actualmente, la función findAndReplaceInText()
devuelve el error 1708. ¿Qué hice mal? La función de buscar y reemplazar proviene de Apple: Guía de scripting de automatización de Mac- Manipulación Texto