Ok i feel like a retard, but i finally create a script from scratch fairly quickly, but cannot figure out why it is saving a file inside and outside of the named file.
Ok i have files set up to save to a folder “CCR4” based upon names and dates of birth. This script automates that but it is saving a files inside and outside of the correct folder simultaneously. i.e. when run creates two word docs.
CCR4 – smith.John.01.01.10.doc and then also
CCR4 – smith.John.01.01.10 – smith.John.01.01.10.doc
I want files stored under their name and dob so the file structure should not have any documents only folders, then inside folders only documents or other folders.
-- script to save files to common drive under naming convention
tell application "Microsoft Word"
-- gets name and DOB from Word Document
set DName to form field result of form field "dName" of active document
set DOB to form field result of form field "DOB" of active document
--set NameDob to DName & "." & DOB
end tell
set theFileName to DName
-- Changes first name to format of last.first
set Fname to text 1 thru (offset of " " in theFileName) of theFileName
set Lname to text -1 thru (offset of " " in theFileName) of theFileName
set DName to Lname & "." & Fname & DOB as text
set dNamecount to (count of DName)
set new_foldername to text 2 thru dNamecount of DName --deletes extra leading space in name
-- Checks to see if a folder exists in file structure under naming routine
tell application "Finder"
set this_folder to "Macintosh HD:Users:bbenjamin:Documents:bbenjamin:BBenjamin:CCR4:" as alias
if (exists folder new_foldername of this_folder) is false then
make new folder at this_folder with properties {name:new_foldername}
end if
end tell
-- saves the current word document
tell application "Microsoft Word"
set sLocation to this_folder & new_foldername & ":" & new_foldername as text
activate
save as active document file name sLocation
end tell
the confusing part is the result under Events and Replies in Applescript editor tells me only one file is created. I’ve copied it below.