Advanced Search and Replace Pre-Written Applescripts

I have written quite a few applescripts that I use on a daily basis on my Power Mac G5. I have newly acquired a laptop that I’m looking to run my applescripts on. The problem is that the path name’s (I think that is the right term) are not named the same:

Old Computer:My Hard Drive:Users:Me:Documents:My Scripts:Script A

New Computer:Macintosh HD:Users:New User:Documents:My Scripts:Script A

I have done some searching and found some “search and replace” scripts that allow you to manipulate text documents. But what I’m looking to do seems a bit more complex. At first I was going to create a search and replace applescript that was going to search through my applescripts and replace the text for the old path name with the new one I assigned for my new laptop. I thought that would solve the problem immediately. But then I thought, I would just have to do it again if something got renamed. I thought of the following way that I think would be a much better approach if it’s even possible. I’m new to writing code all together, so this is a little out of my league.

  1. Have finder (maybe?) find the path name for the “My Scripts” folder on the new laptop.

  2. Get all the files in the “My Scripts” folder

  3. Search and replace all text “My Hard Drive:Users:Me:Documents:My Scripts” with new path name.

I thought this way, even if I renamed something (Hard Drive name, Documents Folder Name, Etc), I could just run the script again and I wouldn’t have to keep typing in the name of the new path before running the script. It would also work if the same thing happened on my desktop as well.

Is this even possible? I read some article reguarding making the path name a variable and a couple other options. But to be honest, it’s a lot of new ideas and lingo to wrap my head around for as new as I am to the game. Any idea’s on how to write this?

Thanks again in Advance. Eveyone on this sight is always most helpful.

all predefined folders can be addressed machine independent
for example:

((path to documents folder as text) & "My Scripts:")

Take a look at the Standard Additions dictionary > path to to see the list of all folders

Try these:

set x to path to documents folder
set x to path to home folder
set x to path to desktop folder

and especially this one:

set x to (path to documents folder as text) & "My Scripts" as alias

Edit: must … type … faster!

I don’t think so, it’s a great completion :slight_smile:

would i apply the same method if I wanted to create the “my scripts” folder in that path name too if it wasn’t created in that documents folder?

Yes. Let’s say it’s in your movies folder. You could use:

set x to (path to movies folder as text) & "My Scripts" as alias

Or if it’s in a folder called miscellaneous in your home folder.

set x to (path to home folder as text) & "miscellaneous:My Scripts" as alias

Thanks. As usual. you guys rock