Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Applescripter

macrumors newbie
Original poster
Apr 27, 2012
2
0
:apple: Hi, I wannt to make an Apllescriptsapp( with Applescript Editor) in which you can make an image to dublicate it with 3 different names ( In the end you have 4 times the same picture with 4 different names). Well, the app should also be able to replace the pics if there were any with the same name before there, but it didn't worked so well right now. Can somebody give me the right code to do that?
Thx


Code:
property destination : "Dance" as alias -- the folder to copy to
property nameList : {"blabla", "dudada", "gsasy"}
on run -- application double-clicked or script run from the Editor
	open (choose file with multiple selections allowed)
end run


on open theseItems -- items dropped onto the application
	"replacing:true"
	repeat with anItem in theseItems -- go through all the dropped items
		repeat with aName in nameList -- go through all the names
			tell application "Finder" -- make a copy and rename
				set name of (((duplicate anItem to destination) to aName) with replacing)
			end tell
		"replacing:true"
               end repeat
	end repeat
end open
 
Last edited:

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
Tips

it didn't worked so well
Is a bit of an understatement but at least you tried.

Code:
property destination : "Dance" as alias -- the folder to copy to

needs to point to a location in the form of :

Code:
"Macintosh HD:Users:yourusername:Documents:Dance"

Your on run handler opens a choose file dialog and does nothing else. If you want to work with theseItems change to :

Code:
set theseItems to (choose file with multiple selections allowed)
The on open handler contains errors as well. It will be much more rewarding if you find the solution yourself. You'll gain valuable knowledge by doing so. Work on it a bit more and if you get stuck again post the code.
 
Last edited:

Red Menace

macrumors 6502a
May 29, 2011
578
226
Colorado, USA
If you also want to duplicate the original file without renaming it, just add another Finder duplicate command after the first repeat statement. Take a look at the Finder's scripting dictionary for information about the duplicate command - "replacing:true" isn't going to do anything.

Edit: forgot that the script copies first and then renames, so the additional duplicate command for the original item would go after duplicating and renaming for the other names (between the end repeat statements).
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.