I want to replace a word in a file then save as a new file.
according to your replaceInAllScripts.script, so I write as this:
set the folder to “/working”
set filename to “aaa.xml”
put file filename into txt
replace “a” with “b” in txt
create file “b.xml”
put txt into file “b.xml”
I try this, but txt is alway empty; the value of file aaa.xml can not be set to txt, so my b.xml is alway empty.
I dont know why? thanks for your help!
It sounds like it’s not finding the file. There are a couple of things you can do to check this. Just before the line “put file filename into txt” in your script, try the following:
put "Pathname: " & the long name of file filename
put "File exists: " & file filename exists
If the pathname looks correct and it says the file exists, then txt should get the contents of the file (as text) unless there is a problem with file permission or file encoding.