text
stringlengths 0
15.7k
| source
stringlengths 6
112
|
---|---|
return theFile | Kevin's Library.applescript |
end makeFileReference | Kevin's Library.applescript |
on readFromFileAs(theFile, theClass) | Kevin's Library.applescript |
local fileReference, fileSpec | Kevin's Library.applescript |
set fileReference to open for access theFile | Kevin's Library.applescript |
set theData to read fileReference as theClass | Kevin's Library.applescript |
return theData | Kevin's Library.applescript |
close access file theFile | Kevin's Library.applescript |
return missing value | Kevin's Library.applescript |
end readFromFileAs | Kevin's Library.applescript |
on fileExists(theFile) | Kevin's Library.applescript |
log "checking for file" | Kevin's Library.applescript |
if my pathExists(theFile) then | Kevin's Library.applescript |
return (class of (disk item theFile) is file) | Kevin's Library.applescript |
on folderExists(theFolder) | Kevin's Library.applescript |
if my pathExists(theFolder) then | Kevin's Library.applescript |
return (class of (disk item theFolder) is folder) | Kevin's Library.applescript |
end folderExists | Kevin's Library.applescript |
on pathExists(thePath) | Kevin's Library.applescript |
log "checking for path" | Kevin's Library.applescript |
if thePath is missing value or my isEmpty(thePath) then return false | Kevin's Library.applescript |
if class of thePath is alias then return true | Kevin's Library.applescript |
if thePath contains ":" then | Kevin's Library.applescript |
alias thePath | Kevin's Library.applescript |
else if thePath contains "/" then | Kevin's Library.applescript |
POSIX file thePath as alias | Kevin's Library.applescript |
end pathExists | Kevin's Library.applescript |
on writeToFile(theFile, theData) | Kevin's Library.applescript |
set theFile to makeFileReference(theFile) | Kevin's Library.applescript |
set fileReference to open for access theFile with write permission | Kevin's Library.applescript |
set eof fileReference to 0 | Kevin's Library.applescript |
write theData to fileReference as «class utf8» | Kevin's Library.applescript |
on error errMessage number errNum | Kevin's Library.applescript |
error errMessage number errNum | Kevin's Library.applescript |
on readPlistAt:thePath | Kevin's Library.applescript |
set thePath to current application's NSString's stringWithString:thePath | Kevin's Library.applescript |
set thePath to thePath's stringByExpandingTildeInPath() | Kevin's Library.applescript |
set theDict to current application's NSDictionary's dictionaryWithContentsOfFile:thePath | Kevin's Library.applescript |
return theDict as record | Kevin's Library.applescript |
end readPlistAt: | Kevin's Library.applescript |
on getKeychainItem(keychainItemName) | Kevin's Library.applescript |
do shell script "security 2>&1 >/dev/null find-generic-password -gl " & quoted form of keychainItemName & " | awk '{print $2}'" | Kevin's Library.applescript |
if result is not "SecKeychainSearchCopyNext:" then return (text 2 thru -2 of result) | Kevin's Library.applescript |
end getKeychainItem | Kevin's Library.applescript |
on throwError(errMsg) | Kevin's Library.applescript |
error errMsg number 1000 | Kevin's Library.applescript |
end throwError | Kevin's Library.applescript |
set thefile to path of document 1 of window 1 | OpenWrodPath.applescript |
open thefile | OpenWrodPath.applescript |
set t to ((path to application support from user domain) as string) | Go-to-Custom-Folder.applescript |
if (count of windows) = 0 then | Go-to-Custom-Folder.applescript |
open thePath | Go-to-Custom-Folder.applescript |
tell front window to set target to thePath | Go-to-Custom-Folder.applescript |
"Hello, AppleScript World!" | hello copy.applescript |
set listOfDocs to name of documents | Numbers to Numbers (Email Transfer).applescript |
set sourceDoc to choose from list listOfDocs with prompt "Choose Source Doc" | Numbers to Numbers (Email Transfer).applescript |
set targetDoc to choose from list listOfDocs with prompt "Choose Target Doc" | Numbers to Numbers (Email Transfer).applescript |
set sourceDoc to item 1 of sourceDoc | Numbers to Numbers (Email Transfer).applescript |
set targetDoc to item 1 of targetDoc | Numbers to Numbers (Email Transfer).applescript |
tell document sourceDoc | Numbers to Numbers (Email Transfer).applescript |
set emailsSource to column "C" | Numbers to Numbers (Email Transfer).applescript |
set usernamesSource to column "D" | Numbers to Numbers (Email Transfer).applescript |
tell document targetDoc | Numbers to Numbers (Email Transfer).applescript |
set emailsTarget to column "I" | Numbers to Numbers (Email Transfer).applescript |
set usernamesTarget to column "H" | Numbers to Numbers (Email Transfer).applescript |
repeat with i from 2 to count of cells of usernamesSource | Numbers to Numbers (Email Transfer).applescript |
set usernameSource to value of cell i of usernamesSource | Numbers to Numbers (Email Transfer).applescript |
set email to value of cell i of emailsSource | Numbers to Numbers (Email Transfer).applescript |
repeat with j from 2 to count of cells of usernamesTarget | Numbers to Numbers (Email Transfer).applescript |
set usernameTarget to value of cell j of usernamesTarget | Numbers to Numbers (Email Transfer).applescript |
if usernameSource is equal to usernameTarget then | Numbers to Numbers (Email Transfer).applescript |
set value of cell j of emailsTarget to email | Numbers to Numbers (Email Transfer).applescript |
set Logger to newLogManager("~/Desktop/AppleScript Log Manager Demo.log") | logManager.applescript |
tell Logger | logManager.applescript |
logMessage("Hello World " & (random number from 1000 to 9999)) | logManager.applescript |
logError("on run", "Some error message", 1234) | logManager.applescript |
logWarning("This is an urgent message") | logManager.applescript |
on newLogManager(aLogFilePath) | logManager.applescript |
script LogManager | logManager.applescript |
property logFilePath : missing value | logManager.applescript |
property parentFolderPath : missing value | logManager.applescript |
property logFileName : missing value | logManager.applescript |
property maxSize : 1048576 | logManager.applescript |
on initWithPath(aPath) | logManager.applescript |
set logFilePath to hfsPath(aPath) | logManager.applescript |
set parentFolderPath to hfsPathForParent(logFilePath) | logManager.applescript |
set prvDlmt to AppleScript's text item delimiters | logManager.applescript |
set logFileName to text item -1 of logFilePath | logManager.applescript |
set AppleScript's text item delimiters to "." | logManager.applescript |
set logFileName to text item 1 of logFileName | logManager.applescript |
set AppleScript's text item delimiters to prvDlmt | logManager.applescript |
end initWithPath | logManager.applescript |
on logMessage(msg) | logManager.applescript |
set ts to timestamp(current date, 1) | logManager.applescript |
set fullMessage to ts & " " & msg | logManager.applescript |
_logToFile(fullMessage) | logManager.applescript |
end logMessage | logManager.applescript |
on logError(fnc, msg, num) | logManager.applescript |
set fullMessage to ts & " [Error] " & fnc & ": " & msg & " (" & (num as text) & ")" | logManager.applescript |
end logError | logManager.applescript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.