New user help .I have looked everywhere but could not find one that will simply make a bunch of “user defined” number of folders and name them sequentially. 1,2,3,4 or 1976,1977,1978.
This seems very useful and I cannot figure out why nobody has written it.
There’s a script by Ray Barber named ‘Alphabot’ that does something similar…
http://scriptbuilders.net/category.php?search=alphabot
Or you can use Applescript and the command line with a do shell script…
do shell script "mkdir {1,2,3,4}"
set dFolder to choose folder
display dialog “choose startnumber” default answer “1” default button “OK”
set startnumber to text returned of result
display dialog “choose number of folders to create” default answer “1” default button “OK”
set quantity to text returned of result
repeat quantity times
tell application “Finder” to set rep to count of every folder in folder dFolder
set folder_name to startnumber + rep as string
tell application “Finder” to make new folder with properties {name:folder_name} at folder dFolder
end repeat
cheers roland
This script actually starts with the number entered (not the number entered plus the number of folders already in the target folder), has error checking, improved performance (since the repeat is inside a single Finder tell block and doesn’t require counting the folders on every iteration), and has the benefit (when saved as an application) to define the target folder through drag and drop:
Jon
[This script was automatically tagged for color coded syntax by Script to Markup Code]
Wowsers Guys, both scripts are equally cool. I modified Jonn8’s script slightly to allow you to put a name before the numbers…
Thanks a ton guys Roland, Jon, Greggo the scripts worked exactly like they were written. I am working on downloading all the Rolling Stones covers since 1967 and so I needed to make all the years- folders and I new there had to be an easier way, and you all were right. I will post the work to share when done.
I’m getting strange results from Jon’s original script. If I enter 10, as the start number and 20 as the end number, it makes folders 10 thru 29 in the destination folder, it gets progressively higher if I use higher numbers eg., 99 thru 105 returns 99 thru 203 folders, I forced a quit (command period) of the script when trying 1990 thru 2003 when it got to 1990 thru 2745 ???
I just upgraded to Mac OS X 10.2.8 6R73, but I didn’t test for higher numbers prior to this. So, I’m not sure what’s going on.
This is the expected behavior. The script isn’t written to go from the first number (start_num) to the second but, rather, start at start_num and make end_count folders. So if you enter 10 for start_num and 10 for end_count, it will create 10 folders starting at 10 and ending at 19. If you set start_num to 1990 and end_count to 2003, you’ll get 2003 folders starting at 1990 and ending at 3992 (2003 total folders). If you want just folders 1990 to 2003, set start_num to 1990 and end_count to 14 (14 total folders). You could modify the script to set a start_num and and an end_num instead of an end_count.
Jon
Ah, I see. Thanks Jon.
Hi Jon and Greg
I am not an AppleScript-Pro. So please, can you tell me the difference between my script and yours. So I can learn more about scripting.
Thanks Roland
Well, as I mentioned above,
The start number change should be clear.
The error checking is in a few places: 1, so that the numbers entered are always checked and the not returned unless the input from the user is, in fact, an integer (and this is modularized through a handler so it can be used more than once for all the numbers required), 2, so that the script stops and notifies the user if a folder with the same name already exists in the target folder.
The improved performance may not be all that noticeable when creating just a few folders but reversing the order of the Finder tell block and the repeat loop, but it is better and should be the way you code things in general. Not counting the folders every time (which is unnecessary since we know how many folders we are creating) should also improve performance but again, will not be that noticeable on just a few folders.
The script was wrapped in “run” and “open” handlers which allows it to be saved as a droplet application to make identifying the target folder easier via drag and drop in the Finder.
Greg’s addition was also a very good one to allow the user to enter a prefix for the folders. I would modify his addition, however, to either eliminate the space between the named prefix and the iteration (the user should enter it if they want when inputting the text for the prefix) or at least checking to see if the user did in fact enter some thing, and, if so, then adding the space. I would also add a property for this so that it will remember what the user last input and offer that as a suggestion the next time the script is run since most likely the user is using the script for the same task. Finally, I would also add a similar routine to ask for a suffix so that the iteration could be first.
Let me know if you have any more questions.
Jon
Thanks Jon for your explanations.
Cheers Roland