Staan er ook $'s in die niet vervangen moeten worden ?
Zoniet, dan vervangt dit script alle $ door @.
on open these_files
set aantal to the count of these_files
repeat with counter from 1 to aantal
set this_file to item counter of these_files
if the name extension of (info for this_file) is "txt" then
set file_text to read this_file
set new_file_text to replace_chars(file_text, "$", "@")
write_to_file(new_file_text, this_file, false)
end if
end repeat
end openon replace_chars(this_text, search_string, 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
on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as text
set the open_target_file to ¬
open for access file target_file with write permission
if append_data is false then ¬
set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file
Het grootste werk wordt verricht door twee handlers die ik van apple's site heb geplukt. Let wel op: dit script past de originele bestanden aan, dus voor het geval er iets mis gaat zou ik eerst even een backup maken van je teksten. Ik heb het namelijk maar met twee tekstbestandjes getest maar wie weet wat er bij 600 gebeurdÂ…
Kies bij het bewaren voor 'Programma' dan wordt het vanzelf een droplet waar de bestanden op kunt slepen.
Veel succes.
(Bewerkt door zonapple om 18:20, 1-04-2005)