I’m a newbie to Applescripting, and I’m trying to make multiple folders from a list of names read from a text file. To test the script I created a plain text file in TextEditor with the following names fldr1, fldr2, fldr3. I hit return after each named and save the file as Test.txt. I ran the following script:
set FolderLocation to "Documents:Tech Summer 2005"
--Open File containing the list of names
set namelist to open for access file "Documents:Tech Summer 2005:Test.txt"
set endOfFile to get eof namelist
set Increment to 0
--Make a Folder for each name read in
repeat until Increment > endOfFile
--Read in name
set folderName to read namelist before paragraph
set countOfALine to the count of namelist
--Make a folder for name read in
tell application "Finder"
make new folder at FolderLocation with properties {name:folderName}
end tell
set Increment to the Increment + (countOfALine + 1)
end repeat
The result of the script was one folder named “fldr1 fldr2 fldr3” and a end of line error. What am I doing wrong?
Thanks in Advance!!!
Model: iBook
AppleScript: 1.10
Browser: Safari 412.2
Operating System: Mac OS X (10.4)
Yeah, yeah now check the method…
They be askin us questions, harass and they test us
Say it man, we eat Applescripts for breakfast
:lol:
set TheFolderNames to paragraphs of (read "YourDiskname:Path:To:Documents:Tech Summer 2005:Test.txt")--This is an example; you need a full path (see below)
set FolderLocation to (path to desktop)--You can hardwire a path here to any location; this is where the folders will be created
repeat with ThisName in TheFolderNames
tell application "Finder"
make new folder at FolderLocation with properties {name:ThisName}
end tell
end repeat
To get the full path to your file, run
set theFile to choose file
and you can copy the path out of the result window without “alias”
SC
Thanks for the reply. The code seems to work, but I get an error the second time I ran it.
On the first run, it creates the three folders correctly and an additional three untitled folders as well.
The second run resulted in the following error:
Can’t make “Documents:Tech Summer 2005:Test” into type file.