Shared Applescript App Quits Unexpectedly
Hello! First off - Thank you to anyone who attempts to give me some help, anything is greatly appreciated. I'm a little stumped. I've written as much attached info to try and describe my problem as possible, but essentailly I'm having trouble sharing a droplet with other mac users.
My computer is:
iMac (21.5-inch, Late 2013)
2.7 GHz Intel Core i5
8 GB 1600 MHz DDR3
Iris Pro Graphics
OS X 10.10.5
I am writing applscript code with
Script Editor Version 2.7 (176)
AppleScript 2.4
App Overview:
The app I've written works on my computer 100% of the time - This makes me think that the code isn't the problem, but I will post it at the bottom regardless. I am not sure what everything I've written is essential for, and a lot of this code was tested through trial and error.
Essentially it takes a dropped folder as input. Asks the user for 2 different inputs of text. It then takes that information, renames the folder, as well as renames all image files inside the folder with sequentially increasing suffixes. Then also changes the names of two different types of files slightly differently.
Problem Overview:
What I'm having a problem with is when I try to send my droplet application to other mac users and having them run it successfully. Originally I had created this same app with the Automater, however it wouldn't run on any other computer (my best guess was operating system incompatibility). So I went and learned as much as I could about applescript, and tried to write the code to be as back compatible as possible. Now when another user attempts to use the droplet it says it "quit unexpectedly". The method to give the app to another user: I zipped the app, then emailed it. In emailing it to myself, opening it and running it, there were no issues here.
I'm not sure if the problem I have is based in the code I've written, or somewhere else along the supply chain.
Error Log from my beta tester (i'm not exactly sure what I am looking at here, but it might be helpful to someone here. I've removed anything that looked to me like it could be sensitive. If it's important, let me know and I can share it)
______________________________________________________________________________
Error Log:
______________________________________________________________________________
Process: launchd [7706]
Path: /Users/username/Desktop/appname.app/Contents/MacOS/droplet
Identifier: com.apple.ScriptEditor.id.Renaming-Copy
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: launchd [98]
Date/Time: 2015-08-28 16:23:09.821 -0400
OS Version: Mac OS X 10.6.8 (10K549)
Report Version: 6
Interval Since Last Report: 1241996 sec
Crashes Since Last Report: 22178
Per-App Crashes Since Last Report: 24
Anonymous UUID: <removed for security>
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xfffffffffffffff8
Crashed Thread: Unknown
Backtrace not available
Unknown thread crashed with X86 Thread State (64-bit):
rax: 0x0000000000000055 rbx: 0x0000000000000000 rcx: 0x0000000000000000 rdx: 0x0000000000000000
rdi: 0x0000000000000000 rsi: 0x0000000000000000 rbp: 0x0000000000000000 rsp: 0x0000000000000000
r8: 0x0000000000000000 r9: 0x0000000000000000 r10: 0x0000000000000000 r11: 0x0000000000000000
r12: 0x0000000000000000 r13: 0x0000000000000000 r14: 0x0000000000000000 r15: 0x0000000000000000
rip: 0x00007fff5fc01028 rfl: 0x0000000000010203 cr2: 0xfffffffffffffff8
Binary images description not available
Model: MacBookAir3,1, BootROM MBA31.0061.B01, 2 processors, Intel Core 2 Duo, 1.4 GHz, 4 GB, SMC 1.67f10
Graphics: NVIDIA GeForce 320M, NVIDIA GeForce 320M, PCI, 256 MB
Memory Module: global_name
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xD1), Broadcom BCM43xx 1.0 (<removed for security>)
Bluetooth: Version 2.4.5f3, 2 service, 19 devices, 1 incoming serial ports
Network Service: AirPort, AirPort, en0
Serial ATA Device: APPLE SSD TS128C, 113 GB
USB Device: FaceTime Camera (Built-in), 0x05ac (Apple Inc.), 0x850a, 0x24600000 / 2
USB Device: BRCM2070 Hub, 0x0a5c (Broadcom Corp.), 0x4500, 0x04500000 / 3
USB Device: Bluetooth USB Host Controller, 0x05ac (Apple Inc.), 0x821b, 0x04530000 / 5
USB Device: Apple Internal Keyboard / Trackpad, 0x05ac (Apple Inc.), 0x0242, 0x04300000 / 2
______________________________________________________________________________
end of error log
______________________________________________________________________________
______________________________________________________________________________
Apple Script: Appologies - I can't seem to format this as an applescript in here. If there is any easier way to display this for you please comment and let me know how and I'll do my best to edit this so it's easier to help me out!
This script is mostly a combination of my own mind and a previously written script here:
https://gist.github.com/oliveratgithub/b9030365c9ae483984ea
______________________________________________________________________________
-- This takes the dropped file and saves it as alias
on open the_dropped_folder as alias
-- saving the text item delimiters
set olddelimiter to text item delimiters
-- this is used to break apart the file name and the extension later
set text item delimiters to "."
tell application "Finder"
-- these are incased in try blocks to fail silently if not all kind's of files are contained in the folder
-- they group like items together by the kind of file they are, for later renaming.
try
get every item of the_dropped_folder whose kind contains "Image"
set the_jpg_files to the result
end try
try
get every item of the_dropped_folder whose kind contains "PDF"
set the_pdf_files to the result as list
set pdf_file to the first item of the_pdf_files
end try
try
get every item of the_dropped_folder whose kind contains "Unix"
set the_ax5_files to the result as list
set ax5_file to the first item of the_ax5_files
end try
-- these two dialogs are the user input that allows the application to rename the files based on the desired output.
display dialog "What is the Folder Name?
(Ex: John Smith 123 Grove Street would be jsh123)" default answer "abc123"
set folder_name to text returned of result
display dialog "What is the Survey Number?
(Usually a 7-8 digit number beginning with 100)" default answer "100xxxx"
set survey_number to text returned of result
-- this is converting the alias files to a list
set all_files to every item of the_jpg_files as list
-- this enters a repeat block, renaming each individual file and adding a suffix before the extension that increases sequentially according to it's place in the index.
repeat with index from 1 to the count of all_files
--using our index, we select the appropriate file from our list
set this_file to item index of all_files
set file_name_count to text items of (get name of this_file)
--if the index number is lower than 10, we will add a preceding "0" for a proper filename sorting later
if index is less than 10 then
set index_prefix to "0"
else
set index_prefix to ""
end if
--lets check if the current file from our list (based on index-number) has even any file-extension
if number of file_name_count is 1 then
--file_name-count = 1 means, we extracted only 1 text-string from the full file name. So there is no file-extension present.
set file_extension to ""
else
--yup, we are currently processing a file that has a file-extension
--we have to re-add the original file-extension after changing the name of the file!
set file_extension to "." & item -1 of file_name_count
end if
--let's rename our file, add the sequential number from 'index' and add the file-extension to it
set the name of this_file to folder_name & " " & index_prefix & index & file_extension as string
end repeat
-- here we attempt to rename a PDF file and an ax5 file if they are contained in the folder at all.
try
set the name of pdf_file to folder_name & " " & survey_number & ".pdf" as string
end try
try
set the name of ax5_file to folder_name & " " & survey_number & ".ax5" as string
end try
-- here the user gets a report on the number of files renamed, as well as what types were processed. This is a bit of a cheat though, because had there been no PDF or ax5 files, the dialog would not change and you would be told falsly that 1 pdf and 1 ax5 file were renamed. This wasn't a big deal to me as the folder's will always be organized the same, the important part is the image renaming.
display dialog "Renamed: " & index + 2 & " Files" & "
" & index & " .jpg files with " & folder_name & " " & "
" & "1 PDF File with " & folder_name & " " & survey_number & "
" & "1 AX5 File with " & folder_name & " " & survey_number
set the name of the_dropped_folder to folder_name & " WIP"
-- returning the text item delimiters
set text item delimiters to olddelimiter
end tell
end open
______________________________________________________________________________
End of Apple Script
______________________________________________________________________________
Thanks again for any help you might be able to offer. Happy to answer any questions to get to the bottom of this problem. Also happy to post this into a different location if this is the wrong one!
iMac (21.5-inch, Late 2013), OS X Yosemite (10.10.5)