Hello there, I’m a newbie here and normally search tirelessly on the web to find things. I noticed here that many will take the time to write a basic script to help others out and that was awesome to see! Well as you can guess, I’m asking for help…
I have ultimately thousands of files (in the end) that I have to take the first three words of the pdf file name and make a folder and put that file or files in the folder. Some times there are 2-6 files that will have the same first 3 words and will go into the same folder…
example: (made up names)
2026 John Doe intake.pdf - Folder would be 2026 John Doe
2026 John Doe application.pdf - File would go into above folder
2026 Mary Smith intake.pdf - Folder would be 2026 Mary Smith
2026 Jack Smith application.pdf. - Folder would be 2026 Jack Smith
The pdf files will all be in the same folder to begin with, but again, there may be several that will end up with the same first 3 words and should go into the same folder. I have found script on a site that names the folder after the file name, I just need that tweaked to only use the first 3 word essentially. or to gather the data before the third space…? Oh, just another bit of info, some names may have a hyphen in them ie 2026 Brenda Smith-Doe intake.pdf and if it make a difference, the file names may be a lot longer than my example like 2026 John Doe application for bluecross mapd direct abhhnthdksj.pdf if that makes any difference.
I need to automate this process so badly, I will make sure you guys are recognized also. My head can’t take more searching for the fix and I wish I knew how to write scripting…! ;/
Here is the script I mentioned that names the folder after the full file name.
tell application “Finder”
set selected to selection
set current_folder to item 1 of selected
set mlist to every file of current_folder
repeat with this_file in mlist
set cur_ext to name extension of this_file
set new_name to text 1 thru -((length of cur_ext) + 2) of (name of this_file as text)
set new_folder to make new folder with properties {name:new_name} at current_folder
move this_file to new_folder
end repeat
end tell
If anyone can help me out… Would help me and this small company immensely!!!
And thank you for at least taking the time to read my first post!!
Brian