Using AppleScript
Hi, I'm trying to create a script that allows me to generate a folder set to a network volume structure.
I currently have the script that works below, but generates the folder on the desktop.
How do I would change this includes a dialog box that would allow me to access a specific folder in a network volume?
I.e. he take me to the next level of volume and allow me to select my desired location to generate files in the subfolder structure.
Any help would be appreciated.
Thank you
Sam
Global jobNum
the value Path of path to the Office - the location to make the folder structure
the value textYear to text - via -1 of 2 ((current date)'s year in the text)
jobNum value to text returned of (display dialog "Please enter the job number:" default of answer {textYear & "xxx"})
the value JobName to text returned of (display dialog "Please enter the name of the job:" default of response 'Working name')
the value JobNumName to jobNum & "_" & JobName
makeFolderStructure of {JobNumName, {jobNum & "_" & "AW_Elements", {jobNum & '_' & 'AW_Downloads', jobNum & "_" & "AW_Approvals", jobNum, '_' & 'AW_Links', {'tiff-eps",""jpg", "DSP", "I"}, jobNum & "_" & "AW_PDF", {"hired", "Rosa"}, jobNum & '_' & 'AW_Photography', jobNum & "_" & "AW_Presenters", jobNum & "_" & "AW_Resource", jobNum & "_" & "AW_Gone_to_Print"}, jobNum & '_' & 'MG_Elements', {jobNum & "_" & "MG_Downloads"}} {, jobNum & '_' & 'MG_Renders', {'Rosa', 'Final'}, jobNum & "_" & "MG_Imports", {"have", "audio", {'bought', 'Reference'}, "eps - tif', '" jpg', 'psd', 'video'}, jobNum & "_" & "MG_Resource"}, jobNum & "_" & "CR_Elements", {jobNum & "_" & "CR_Presenters", jobNum & "_" & "CR_Downloads", {'bought', 'Référence'}, jobNum & "_" & "CR_Photography" jobNum & "_" & "CR_Resource", jobNum, '_' & 'CR_Scamps' jobNum & "_" & "CR_Copy" {{, jobNum & "_" & "CR_Working" {"Illustrator", "indesign", "photoshop"}}} to path
someItem to someFolder to makeFolderStructure
parentFolder put to someFolder
if class of someItem is list then
Repeat with anItem in someItem
if class anItem is list then - add subfolders
anItem to someFolder makeFolderStructure
else - add a new child folder in the current parent
Journal anItem
say application 'Finder '.
create a new folder to parentFolder with properties {name: anItem}
the value someFolder the result as alias for
If anItem begins by jobNum & "_AW_" then set label of someFolder at index 6 - Green
If anItem begins by jobNum & "_CR_" then set the label index of someFolder to 3 - yellow
If anItem begins by jobNum & "_MG_" then set the label index of someFolder to 5 - purple
If anItem contains "CR_Presenters" then
the value lanFile in a file 'XXXXXXX_CR_presenter_STX_VX.indd' from folder 'Presenter_Master' of the disk "Macintosh HD".
duplicate {lanFile} to someFolder
end if
end say
end if
end Repeat
else - add a single folder
say application 'Finder '.
create a new folder to someFolder with properties {name: someItem}
the value parentFolder the result as alias for
If someItem begins by jobNum & "_AW_" then set label of parentFolder to index 6 - Green
If someItem begins by jobNum & "_CR_" then set label of parentFolder to index 3 - yellow
If someItem begins by jobNum & "_MG_" then set label of parentFolder to index 5 - purple
end say
end if
end makeFolderStructure
GLO
Replace the second line with:
the path value (choose the folder)
(143942)
Tags: Mac OS & System Software
Similar Questions
-
How to use AppleScript to create a menu shortcut in figures?
Does anyone know how I can create a pop up menu numbers using AppleScript.
say application "Numbers".
activate
say le first table of the sheet active of the document 1
the value the format of cell "B3" to popup menu
end say
end say
I can create a pop up menu by using this code, but this is the default list.
If I have a composed list {'mouse', 'Keyboard', 'Trackpad'}, how would be to create a context menu with these items?
Thanks in advance.
Steve Longley
Hi Steve,.
I wonder why you feel the need to use (or what you think you would get to use) an AppleScript to create a cell in the context menu.
With the help of numbers 3, it's a fairly simple process:
Open a table, or use a column with enough empty cells to accommodate the menu in the menu items.
Access to the list of items of a line in your column.
Select all cells that contain entries.
Open the Inspector to Format, choose the cell, choose the context menu.
Any selected cell now contains the same menu, each set to the original value in this cell.
If you want that each menu includes a "white" cell, then:
Select all the cells (three).
Modify the beginning with... pop - up 'Start with white '.
Click on one of the cells, and then click control v next to the cell to display the menu choices. Each cell contains the same menu with the value initially entered in the selected cell, so what a no point, which will produce a cell empty, at the top of the list.
The menu can be copied and pasted into other places or can be filled in the column or line using the handles to fill yellow appearing in the centres of the edges of the cell when the mouse cursor is brought near. The cell glued/filled setting will be the same as that of the pasted source cell.
Kind regards
Barry
-
Use AppleScript to open boxes smart mailboxes
Is it possible to use AppleScript to open/view a specific smart mailbox in mail?
I have a Microsoft Exchange e-mail account in Mail, with several boxes to letters and emails stored in each. The name of each mailbox corresponds to a name of a certain record/entry in a FileMaker Pro 13 database. I would like to have a button in every record/entry in the FileMaker database, once clicked to run an AppleScript script which will be open / view of the mailbox in mail for that particular record.
For reference, I'm under FileMaker Pro 13, Mail (v9.3) on OS X El Capitan (v10.11.4).
Is it possible to use AppleScript to open/view a specific smart mailbox in mail?
I don't know anything about Microsoft Exchange or FileMaker Pro.
However, the following GUI script may select a smart mailbox under OS X 10.11.3.
the value theSmartMailboxName to 'TEST' - replace 'TEST' with any name of your choice
say application "Mail".
launch
activate
say application 'System events' to say process "Mail".
key sequence '0' using {control down}
If subrole of window 1 is "AXFloatingWindow" then click on the button 1 of window 1
if not (are scrolling area 1 of the Group splitter 1 of window 1) then
key sequence "m" using { control down,shift down}
end if
say 1 1 of the Group splitter 1 in structure window scrolling area 1
Select (row 1 of which value of text field 1 of UI element 1 is theSmartMailboxName)
end say
end say
end say
Also take a look at this article.
-
Want to know how to find the alias to a random file using applescript
Hi, I was wondering if I can find the alias for any file that I even clicked on using applescript.
I searched online, and there is not much that I can take some.
So, for example in applescript I "put fileToFind to alias (...)" but this alias depends entirely on the single user, click on the file. So I do not know this alias exactly, is there a way that I can put this variable "fileToFind" to an appropriate alias of the file I even clicked on?
single click
Info (CMD + i)
-
How can I add the speaker notes to a slide using applescript?
How can I add the speaker notes to a slide using applescript? I am able to create slides, add a title and bullet points, but when I try to add the speaker notes, it does not work.
say thisSlide
-set the title
set the text of the object to the default title at "TITLE" element
-create a bulleted list
the text of the object of the item to the default body ¬
"Bullet Point 1" & return & "Bullet Point 2" & return & "Bullet Point 3"»»
-put the presenter notes
¬ the text value of the object of the presenter notes
'' Here is my presenter notes.
How can I add the speaker notes to a slide using applescript?
Maybe like this:
say thisSlide
-put the presenter notes
Set presenter notes to "here is my presenter notes.
end say
-
Path of the most recent added file using applescript
I use appleScript Automator to download new pictures on my Instagram.
The script trigger when the new file is added to a folder "updates".
Open the app (work)
activate an application "Uploader HD for Instagram"
delay 0.5
Tell application "system events".
say "Uploader HD for Instagram" processes
Click on the menu "open...". "the menu 1 menu bar item 'File' from the menu bar 1
tell the end
tell the end
Activate the "go in the folder" CMD + SHIFT + G
Tell application "system events".
delay 1
combination of keys 'G' using {control down, moving down}
delay 1
tell the end
This is the problem... I "Don't KNOW" the name of the most recent added the file and there are a lot of files on the folder... So I can't use the full path of the file on the 'go in the folder ".
Tell application "system events".
combination of keys "/ Users/HazaelDiaz/Google Drive/IFTTT/Instagram/update/2016 / '.
delay of 0.1
strike back
delay of 0.1
strike back
tell the end
Since I trigger the 'applescrip' using the 'Workflow folder action... " Is it possible that I can get the value or the path of the new file included?
I found a code that renames all the files from 0 to xxx folder action, but the new included file is always the last of them on digital process... is possible to rename the files and give the new file name "update1.jpg" first?
Also I can order "Go to folder" action must seek that specify the file: 'update1.jpg. '
This is the script name change: (BTW, these scripts always ask me to select folder... and what I want is to be automated out of my interaction with but do not know how to change so it will always use the "updates" folder
Tell application "Finder".
a in each file of the entire contents of the value (choose the folder)
Repeat with aa in one
the file_name my MakeBase (aa AsString) value
If file_name is not 'JUMP' then
count_er Set 1
the value all_files (all files in aa)
Repeat the operation with ff in all_files
the name value of ff ((texte-3-1 par le biais de ("000" & (count_er as string))) & "." & (name extension for ff))
Set count_er to count_er + 1
end repeat
end if
end repeat
tell the end
to MakeBase (txt)
the value astid delimiters to point to the text of the AppleScript
the text value of the point AppleScript delimiters «:»
the value for each item of text txt new_Name_Raw
the text value of point AppleScript delimiters to "_".
the value final_Name for each item in new_Name_Raw text text
the text value of the point AppleScript astid delimiters
If length > 251 of final_Name then set final_Name on 'SKIP' - will be more than 4 characters for counter
return final_Name
end MakeBase
Any help will be much appreciated.
Thanks /.
What version of Mac OS X are you running?
-
'//Div' XML rule processor cannot find using applescript
Hello world!
In indesign xml pre processor, impossible to find "div" element from xml using applescript.
I try a code but in this case does not. Please give some ideas...
This is my code:
Tell application "Adobe InDesign CS6"
the value of the xpath to {"//div"}
the value of myRuleProcessor to processor rule XML with properties {rule paths: xpath}
myRootXMLElement the value of the XML 1 of 1 item
say myRuleProcessor
the value myMatchData to start to deal with the initial element of game myRootXMLElement rule
Repeat while myMatchData is not equal to nothing
Define myElement to get the item of myMatchData
Select myElement
Set myMatchData for nothing
end repeat
tell the end
tell the end
Thanks in advance.
Hi John,.
It does not seem to accept the tag name "//div. Change it. It worked for me. Hope this can be done in production
Thanks Stefan
-
How can I use applescript to move objects to a specific position on the page?
I have a PDF file with a bunch of items of text on each page, but the margins are irregular. I want to automate the following process:
1. Select all the objects on the page
2. move objects (such as a group, i.e. preserving their arrangement relative to each other) until the upper left corner of the object of most of the top-left {. 67 ", 1"} from the upper left corner of the page.
3. go to the next page.
4. Repeat steps.
I work on a mac, and I see that Acrobat is scriptable using Applescript. Is it possible to do it with this? If there is another way to describe this process without Applescript, I'd be open to that as well.
Thank you very much.
Acrobat has no interface for scripts change the position of an ordinary object.
-
Using Applescript for formatting lines in figures
I have a Numbers spreadsheet where I want to shade the lines according to the (odd) values in my second column (B).
I've been everywhere in the forum, but I can't seem to find a script that is, and I can't change one and make it work.
Anyone with a few kind words and a model? :-)
Hi jsteinaa,
Here's a method that does not require an Applescript.
Add another column, C. You can hide this column later.
Formula in C2 (fill down)
= IF (ISEVEN (B2) ", B2," "")
If a value of B is the same, that the cell equal to the B cell c, otherwise insert "" (NULL).
Conditional highlighting b
Variation: use the ISODD C function.
Please call with questions.
Kind regards
Ian.
-
How to transfer GPS coordinates from one film to the other using Applescript?
When I export a movie from the Photos app and read it in Quicktime Player.
QTP then gives me the location where the film was saved:
Now, I would like to set the location of another movie in exactly in the same place, using Automator or Applescript.
Could someone please give me a tip how to do this? Is this possible?
The reason why I want to do is I want to improve an Automator workflow, I wrote which helps the compression of movies that I keep in my library of Photos (that is, to reduce the size of the file).
The workflow, you can find here (http://www.informatik.uni-bremen.de/~zach/software/index.html#compress_movies_in _photos), if you are interested.
Tips, pointers and suggestions will be highly appreciated.
Best regards
Gabriel.
Hard to do standalone AppleScript, but easy if you install a copy of exiftool
Then, you can extract the GPS coordinates via something like:
the shell script "" / usr/local/bin/exiftool - GPSPosition some. "." JPG ".
You can also use exiftool to copy the tags of one file to another:
the shell script ' / usr/local/bin/exiftool - tagsFromFile - GPSLongitude source.jpg - GPSLatitude dest.jpg.
This will copy the tags GPS Longitude and Latitude of source.jpg to dest.jpg
-
Hello AppleScript and Automator Pros!
Unique ID Elements Quantity Unit of measure Sum, $ Color Dark? 1 Pencil 1 Agenda 90.50 P Yes 2 Pen 150 Agenda 300.23 THERE NO. 3 Pillow 2 Agenda 400.01 B NO. 4 Toy 114 Agenda 500.30 R Yes 5 Repair service N/A N/A 1.00 N/A NO. 6 Phone 98 Agenda 1986.10 W NO. P = purple
Y = yellow
B = black
R = red
W = white
It was an example of Document numbers
Now the example of Document Pages
[PH for Unique ID] - Ben got: [PH for element], [PH for quantity] [PH for unit of measure], [dark or not PH] [PH for color] for [PH for sum before the comma] $ [PH cents] c.
When Ben had [PH for quantity] [dark or not PH] [PH for Color] [PH for item tiny first character and changeable if necessary end], he became happy
Example 1: Allows you to take data from line with Unique ID 1 and that's what it takes to go:
1 - Ben got: pencil, 1 point, violet dark 50 ° c for $ 90.
When Ben had 1 Purple Pencil dark, he became happy
Example 2: Now data row with Unique ID 3 and it is what to get:
3 - Ben got: Pillow, 2 pieces, blue for $ 400 01b
When Ben had 2 blue pillows he became happy
Example 3: Now the data used to row with Unique ID 5 and this is what it takes to get:
5 - Ben got: repair service, 1 service, for 1$ 00 c complete
When Ben had 1 repair service complete, he became happy
Here, I have to change given n/d of the table in numbers and replace quantity with 1 PH, PH for unit of measure with service (no point as in the previous examples) and the PH for color with plenty of example.
-
Script using AppleScript GUI does not
Before we go too complicated, I'm starting to get a basic copy/paste using keyboard shortcuts to work. In theory, if I can copy a value of cells in another cell using keyboard shortcuts, I can use keyboard shortcuts, I need more complex scripts.
Can someone more well informed that I look over the below basic code and tell me what I'm doing wrong?
(I added the script editor to the security settings for accessibility to allow him to control the computer.)
My code for a simple copy/paste in figures (other programs also not to answer):
on run
say application "Numbers".
activate
if not (there are document 1) then error number 1000
say document 1
tell the worksheet active
the value the selectedtable to (the first table whose class of selection range is range)
the value myRows to count the lines in selectedtable
say selectedtable
the value the selection range of cell 2 of rank 3
sendCopy
the value the selection range of cell 4 of rank 3
sendPaste
end say
end say
end say
end say
end run
on sendCopy()
say application 'Numbers' to Activate
say application "System events".
say application process "Numbers".
key sequence « C »
end say
e nd dire
end sendCopy
on sendPaste()
say application 'Numbers' to Activate
say application "System events".
say application process "Numbers".
key sequence « V »
end say
end say
end sendPaste
Thank you
Jason
You favorite the AppleScript Language Guideand then use the appropriate syntax:
key sequence Using 'C' command down
key sequence 'V' with the command down
It may or may not be other contributory factors in your script as to why it does not work.
-
Using AppleScript (run as application)
I used automate this script:
Tell application "system events".
say 1 group of tabs in the window "Keyboard" of the process of "System Preferences."
check the box "Use all F1, F2, etc. as standard function keys keys"
tell the end
tell the end
I save this as an Application, but when I run the application, I get an error.
"The"Run AppleScript"action has encountered an error."
Is there anyone who can tell me how to solve this problem?
I connect remotely to work on a Windows PC where I use Excel a lot.
I'd really like to have a script for Quick-change my function keys settings.
A reason to wrap the Applescript in Automator?
Economy to try as an Application in Applescript
-
Use applescript for Python Shell command
Is there a way where I can make applescript to view the output of the python script and also accepts input so that it can pass it to the python script? My script contains several entry so is it possible possible to do? For more than once in entry and exit every time?
You can certainly create handlers AppleScript (functions) that use Python HERE documents, with AppleScript variable passed into Python as command-line arguments, or returned to AppleScript. AppleScript's display of limited capacity, but does not preclude a cocoa of coding, or TCL GUI for the display format most of in the Python code.
You can also write a Python application that can invoke AppleScript, pass the values on the command line values and return to Python AppleScript. This can be done through a presentation of subprocess or directly through NSAppleScript.
Here's an AppleScript that uses a Python Manager to glance in a .docx Word document and display the names of fonts used in it. Only .docx, not. doc. Notes to escape the double quotes and back-slash in the Python script to appease AppleScript.
-wordfonts.applescript
-display fonts (read-only) in the Word (.docx only) document in the menu drop-down
-VikingOSX, 01/2016, support Apple community
-Version 1.2, the additional list comprehension to Python print statement, other settings.
property docx: {'org.openxmlformats.wordprocessingml.document'}
property mydefault: ((path to the documents folder) as text) as alias
Try
the value docxfile to POSIX path of (Choose file type docx default location mydefault without invisible)
If result = {return button: 'Cancel'} then error -128 - cancelled by the user
say application 'System events' to the value docxname to the name of (POSIX file docxfile as alias)
display the dialog box "Document:"& docxfile & return & return & (elements of my docxfonts (quoted form of docxfile)) as text with the title "Word Document Fonts" give up after 20.
we errnbr error error message number
Error_Handler (errnbr, errmsg)
end try
return
on docxfonts (thefile)
return the shell script "python".
import the zip file
import re
Import os
import sys
fonts =]
thedocx = os.path.expanduser(sys.argv[1])
If not thedocx.endswith ('.docx'):
raise exception ("not a valid docx Word document'")
If zipfile.is_zipfile (thedocx):
with the zip file. Zip (thedocx, 'r') as docxzip file:
XMLDATA = docxzip.read('word/fontTable.xml')
fonts = re.findall (r'(?<=w:name=)\"([ \\w+]+)\"="">', xmldata))
print (------"} \".format ('\\n'.comes ([x for x in sorted (fonts) if fonts])) ")
EXPRESSIONS OF FOLKLORE. "
end docxfonts
on error_handler (nbr, msg)
return Display alert «["& nbr &" "']" & msg as critical leave after 10 "»
end error_handler
Python script that illustrates the passage of an argument to an AppleScript application that runs as a subprocess.
=w:name=)\"([>#! / usr/bin/env python
# coding: utf-8
# dx.py: illustrates the passage of a Python variable in a function that
# contains a string variable (ascript) which is the AppleScript
# code that osascript runs in the sub-process. The value of allow
# following the scriptname as ARGV 1, which is taken by the
# argv clause of AppleScript.
# Use:. DX.py
# VikingOSX, 12/2015, Apple Support communities
# v1.2
import of subprocesses
Import atexit
import sys
MSG = 'the value of x is 10'.
procs =]
def send_dialog (allow):
AScript = "'
on run argv
Set userCanceled false
If (argv County) = 0 then
Tell application "system events" to display dialog ¬ "argv is 0". "
After 10
on the other
the value of msg (item 1 of argv) text
end if
Try
Tell application "system events" to display dialog ¬ msg
with the title 'Application Communication' give up after 10
the error number - 128
userCanceled set to true
try to end
If userCanceled then return "Cancel".
return
end of race
'''
Try:
proc = subprocess.check_output (['osascript', '-e', ascript, allow])
If "Cancel" in proc.decode('utf-8'): # the user presses the Cancel button
sys. Exit ("User Canceled")
except subprocess. CalledProcessError as e:
print (' Python error: [% d]\n%s\n' % e.returncode, e.output])
generator of # @atexit.register to clean any stray sub-process
def kill_subprocesses():
for proc in procs:
proc. Kill()
def main():
send_dialog (MSG)
If __name__ == "__main__":
sys. Exit (hand ())
-
How to remove characters from a file name using applescript
Hello
I use an AppleScript to write files from an application.
The files are written as JPEG and PDF files
I want to omit parts of the name of the JPEG file
Name of the file looks like this, 70618_MEN_327926_2200x3480_1.jpg
I need to be renamed on output, 327926_1
That is to say, delete all characters to the end of the second line of underscores, so all characters after the third underscore and leave all the characters after the fourth underscore character.
Hello
You can use a Manager, like this (Manager contains explanations):
------------------------
tNom set to "70618_MEN_327926_2200x3480_1.jpg".
Set newName to my getChars (tName)
-the result is "327926_1.jpg".
on getChars (t)
value {oTid, point text delimiters} {text item delimiters, '_'}
the entire at t text elements - divide the text using the line underscore as separator, the result is a list of items
If (count l) > 4 then - at least 4 characters to underscores
the charsAfter4_ value to (points 5 thru - 1 l) in the form of text - the text after the fourth underscore
the value charsBetween2_3_ in section l 3 - the text between the second and the third underscores
the value t charsBetween2_3_ & "_" & charsAfter4_ - concatenate two strings
end if
set the text of the delimiters to oTid - reset point of text delimiters
return t
getChars end
-
execution of math on a list of numbers using applescript
I have three columns of numbers in a text file (using BBEdit, impossible to use numbers as there are more than 1 million lines):
299400 3275700 - 57.9788
299500-3275700 - 57.9811
299300 3275600 - 57.9346
299400 3275600 - 58.0249
299500-3275600 - 58.0026
...
I simply multiply the last column (what happens to start by "-") by the value of 0.75, but I am confused.
Beginning AppleScript, so I looked everywhere for example scripts manipulation of numbers but not lucky to have.
So far, I have this:
"But I get this error message: error "cannot make characters 16 through 23 of \"tmp_ITFR2000.txt\ text document" application \"BBEdit\" number. "- 1700 characters 16 to 23 of 'class TxtD '"tmp_ITFR2000.txt"to the number of number
I have to somehow dimension
> a number variable? Thank you
Jim
Use the following line:
output to found the results as a string as a number object
(137021)
Maybe you are looking for
-
App Gallery hangs when you try to save the changes
After cropping of a photo in the gallery app, it crashes when you try to save changes to the photo. It does not occur when recording other changes.
-
Satellite A205 and 4 GB RAM problem
Well today I got a new stick of Ram DDR2 2 GB, bringing my total Ram to 4 GB. However, my computer recognizes 3 (3070 MB) to be exact. I am running Windows 7 64 bit. I'm guessing that the issue has to do with * remapping memory in the Bios is enabled
-
Nobody knows why the mouse Apple Magic mouse has these gliders made of plastic which does not slip on the bottom? I don't understand why something that costs so much is so impractical. There are also two batteries while all other wireless mouse I've
-
Hello I considered buying a Z420, and I intend to use maps of Titan since I rendered by GPU, as well as the CAD uses and in real time. (Autocad, Revit and 3d Max). I've used a Quadro 4000 card, but it is certainly not useful for real time rendering.
-
Example: Pavilion dv6: 10 Windows
Hello I have a problem. I want to book 10 windows, but I don't see the app 'Get windows 10' at the bottom of the screen rigt. I tried everything but nothing works, that is why I ask you, can anyone help me get this windows 10 reserve... application s