Me gustaría extraer el nombre de una lista de texto.
Resultado de do shell shell
comando:
set Clist to do shell command "ls ./"
Es:
John_01044445558_pass.jpg<br>
Jane_01044562738_visa.jpg<br>
Doe_01027381938_pass.jpg<br>
Joe_7485.jpg
Necesito John
Jane
Doe
Joe
de esa lista en este formato:
John, Jane, Doe, Joe
¿Cómo puedo conseguirlo?
Aquí está el script.
tell application "Finder"
set fullname to name of (selection as alias)
set Cdate to do shell script "date '+%Y.%m.%d'"
set AppleScript's text item delimiters to {"_"}
if fullname contains ".jpg" then
set CnameNFD to first text item of fullname
set Cmobile to second text item of fullname
set Ccustomer to second text item of fullname
set Ctemp to "/Volumes/homes/macbook/Save/"
set Clink to "https://r.loyverse.com/dashboard/#/clients/database?page=0&limit=10&search="
set Cname to ¬
do shell script "echo " & (CnameNFD as text) & "|iconv -f UTF-8-MAC -t UTF-8"
--Save
-- set Cppl to do shell script "Ctemp=" & Ctemp & " Cmobile=" & Cmobile & ";ls $Ctemp | grep $Cmobile | awk -F'_' '{print $1}' "
set Cppl to do shell script "Ctemp=" & Ctemp & " Cmobile=" & Cmobile & ";ls $Ctemp | grep $Cmobile "
set lsOutputAsList to ¬
paragraphs of ¬
Cppl
set theNamesList to {}
repeat with thisItem in lsOutputAsList
copy first text item of thisItem ¬
to the end of theNamesList
end repeat
set AppleScript's text item delimiters to ", "
set theNames to theNamesList as text
set AppleScript's text item delimiters to {""}
do shell script "Cname=" & Cname & " Cmobile=" & Cmobile & " Ccustomer=" & Ccustomer & " theNames=" & theNames & "; echo \"'$theNames'\""
si no mostrar diálogo " ." botones {"Okay"} botón por defecto 1 end if end tell
Si despliego el diálogo theNames se muestra como esperaba. Pero si ejecuto con shell script echo theNames no muestra nada. Necesito usar la variable theNames para curl post.