OK, thanks for the post on AS. Back to the issue. I’m having the same issue with that handler. So first, I’ve tested the handler that works:
on replace_chars(this_text, search_string, replacement_string)
-- replace_chars(message_string, "string_to_be_replaced", "replacement_string")
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
set f to "alpha bravo charlie delta echo"
log f -- (*alpha bravo charlie delta echo*)
replace_chars(f, " ", "_") -- works, but no output
log f -- no change to f, output (*alpha bravo charlie delta echo*)
log replace_chars("alpha bravo charlie delta echo", " ", "_") -- (*alpha_bravo_charlie_delta_echo*)
log replace_chars(f, " ", "_") -- (*alpha_bravo_charlie_delta_echo*)
Full list of Events:
[format]
(alpha bravo charlie delta echo)
(alpha bravo charlie delta echo)
(alpha_bravo_charlie_delta_echo)
(alpha_bravo_charlie_delta_echo)[/format]
Here’s my test script for modifying new foldernames, replacing " " with “_”:
on replace_chars(this_text, search_string, replacement_string)
-- replace_chars(message_string, "string_to_be_replaced", "replacement_string")
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
set mylists to {"test 1", "another test 2", "third test playlist"}
set desktoppath to path to desktop
set basepath to (desktoppath & "tfolder") as text
log basepath
tell application "Finder"
try
delete folder basepath
-- delay 2
end try
make new folder at desktoppath with properties {name:"tfolder"} -- This works
repeat with this_playlist in mylists
set myCompliantFolder to replace_chars(this_playlist, " ", "_") -- This is the highlighted method upon error
set tester to basepath & this_playlist
log myCompliantFolder
log tester
make new folder at basepath with properties {name:replace_chars(this_playlist, " ", "_")}
-- I've also tried the method in the first parameter placement, also doesn't work.
end repeat
end tell
error, same result in both set myCompliantFolder and the first parameter inside the new folder property {name}:
[format]error “Finder got an error: Can’t continue replace_chars.” number -1708[/format]
So after cleaning it up, the error remains. Not sure how to implement it as the previous one works.