0

I have multiple applescripts which I need to edit replacing the same text in each (it is an amended prefix to a file name). Is there a way to write an applescript to edit other applescripts. I have to edit over 700 scripts where an new prefix has been introduced.

Thanks in anticipation

  • Can AppleScript be opened in a text editor? If yes, you can try Notepad++, Notepad++ has the ability to in many documents. I am sure if you do a google search, there are many more tools that do the same. – Eric S Apr 21 '16 at 17:32
  • 1
    Grab any text editor, for example https://www.sublimetext.com/3 open the directory with scripts with it and you can then run find-replace on all scripts – Entea Apr 21 '16 at 17:37
  • Thanks Entea and Eric, I opened the script in SubEthaEdit but it reads like gobbledygook. It has loads of strange characters and has become unreadable although it is fine when it opens in Applescript editor. – user3260288 Apr 21 '16 at 19:16
  • for next time, I suggest you to use subroutines in separate scripts (using load command), like a library of your scripts. Doing so, when you wan too change one routine, you just do in the library and all your 700+ scripts will use this new version. – pbell Apr 22 '16 at 06:37
  • Thanks for the suggestion, these are subroutines. I cannot see any way that I could simplify the scripts to accommodate these simple changes. My biggest issue now is that I cannot read my scripts in a text editor as they appear like machine code. As I am sure you realise I am not a professional scripter I am a photoshop artist. Any help would be welcomed. – user3260288 Apr 22 '16 at 06:49
  • @user3260288 I have never worked with AppleScript but this post may be able to help. http://stackoverflow.com/questions/2164410/alternatives-to-applescript It looks like some other editors are listed and might provide the feature you need. – Eric S Apr 22 '16 at 13:47
  • I have solved the problem by using Smile from Satimage instead of the Apple's Script Editor, it has a much greater range of scripting facilities. Thanks for your help. – user3260288 Apr 24 '16 at 07:47

1 Answers1

0

Script Editor is itself scriptable, or you could use the command line osadecompile and osacompile tools. Main thing is to make sure whatever you're using to do the find and replace (simple text substitution, regular expression, whatever) only matches the text you intend it to match, so you don't screw up other parts of your code by accident.

foo
  • 3,171
  • 17
  • 18