make copies of applescript

can anybody help me
I have a script name “01” that opens a file call “01.pdf”

Now I want to make another script name “02” that opens a file call “02.pdf”

I have to make hundreds sript like “01,02,03,04,…so on” this script opens the files like “01.pdf, 02.pdf, 03.pdf, 04.pdf,…so on”

Is there any way or script that on run create a new copy of script “01” and name it “02, 03, 04,…so on” and even change the pdf file name inside the script, so each script opens the same number pdf.

please help :shock: :shock: :shock:

appreciate all sugestion

OR just let me know is it possible.
OR some thing near to this task.

Yes, it’s possible. Do you require a script for each pdf file, or will it be ok to have one script that does the whole job? Please provide as many details as possible about what you need to accomplish. :slight_smile:

Yes, I believe it is possible, though it may require extra tools.

If I understand you correctly, you wrote an applescript (called 01) whose sole task is to open a file called “01.pdf”? Are aliases/symbolic links inappropriate for your purpose? The creation of those can be applescripted.

I believe the script editos Smile (free) and Script Debugger are themselves scriptable, and so it would be possible to write a script then compile + save it in one of those two programs.

It is also possible (I think) to write a script that will store the file name of any file dropped it on, then duplicate itself, giving the duplicate a new name based on the file name of the dropped file. I think this pseudocode describes such a script:

property fileName : “”
on droppedItem
– if file name is empty:
– confirm droppedItem is a file
– set fileName to name of dropped item
– duplicate itself
– rename the duplicate based on the droppedItem name
– set fileName to “”
– else (that is, file name already has a name in it)
– do nothing (or warn user)
– end

but of course, then you must drop the items on the script. That’s quite a chore for 100+ items.

thanks you
now i am sure it can be done

Here is what iam doing
I have a flash projector that has a button, which on click runs an applescript to open a PDF file. i am doing so because flash projector cannot open external files

button “01” runs script “01” to open “01.pdf”
button “02” runs script “02” to open “02.pdf”
button “03” runs script “03” to open “03.pdf”

So now I have to write the script for each buttons that opens PDF files
I already have a simple script “01"to open “01.PDF” file
Now i want a script that on run create a new copy of “01” and name it “02,03,04,…” and change the target file name of PDF file from “01.pdf” to " 02.pdf, 03.pdf, 04.pdf…” which is in the content of script.

It would be great if i only one script that does the whole job as ROB talks about.
And if not I will be happy to have some work around.

Once again thank you very much for your concern.

Well, lets see if we can do this. The following script will attempt to open the pdf file which shares the same name as the script. So if the name of the script is 01, it will attempt to open 01.pdf. It will then create a script named 02 and script 02 will attempt to open the pdf with the same name - 02.pdf. Each script will generate the next script in numerical order.

tell application "Finder"
	set pathToMe to path to me
	set myName to name of pathToMe
	open file (myName & ".pdf") -- this line may need some work.
end tell

set nextNumCalc to (myName as number) + 1
if nextNumCalc is less than 10 then
	set nextNum to "0" & nextNumCalc
	set nextNum to nextNumCalc
end if

tell application "Finder"
	set newScript to duplicate pathToMe
	set name of newScript to (nextNum as string)
end tell

Warning: Even if it works as desired, the script should not be considered complete. For instance, it should check to make sure that a file name isn’t already in use before attempting to name the next script in the sequence. Hope for the best and plan for the worst! :slight_smile: