Run the applescript on multiple folders at a time ?

Joined
Nov 2, 2016
Messages
1
Reaction score
0
Points
1
Hey guys, I have a script that works great but the problem is, it works only one folder at a time

I need to run it on more folders at a time. Is it possible ?

Thank you guys !


Code:
on run {input, parameters}
	
	tell application "Finder"
		
		set dir to container of (item 1 of input) as alias -- get the parent folder
		
		set folderName to name of dir -- get the name of the parent folder
		
		
		
		set r to duplicate file "20.jpg" of dir
		
		set the name of r to "zoom_side.jpg"
		
		
		
		set r to duplicate file "23.jpg" of dir
		
		set the name of r to "zoom_sole.jpg"
		
		
		
		set the name of file "22.jpg" of dir to folderName & "-4.jpg"
		
		set the name of file "20.jpg" of dir to folderName & "-2.jpg"
		
		set the name of file "19.jpg" of dir to folderName & "-1.jpg"
		
		set the name of file "21.jpg" of dir to folderName & "-3.jpg"
		
		set the name of file "23.jpg" of dir to folderName & "-5.jpg"
		
	end tell
	return input
	
end run
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
You haven't explained how you getting the input to your on run handler, so I'll assume your trying to create a dropplet application.
In which case you need an on open handler to process dropped system files or folders.

Here's a very basic simple example, using a repeat loop to process each dropped item.

Code:
on open theDroppedItems
	repeat with i from 1 to count of theDroppedItems
		try
			set theItem to item i of theDroppedItems
			set theItemInfo to info for theItem
			display dialog "Name of the dropped file system item is " & name of theItemInfo
		on error
			display alert "Error occured with the dropped file system items." as warning giving up after 30
			exit repeat
		end try
	end repeat
end open

Paste the above code into a new Script Editor file, and save it to your Desktop as an Application file, and not as a Script file.
Then drag multiple files or folders from Finder to the new Desktop application icon on your Desktop, and see it loop thropugh each item.

Hope this is the kind of thing you were after.

If your not creating a dropplet, but an AppleScript application with the ability to select different folders for processing it's contained files, then the answer is similar, simply use a repeat loop to process each folder in turn.

Regards Mark
 
Last edited:

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top