Pass results of one script to another?
I have 2 scripts: The first converts a Word document into a PDF, the second splits the PDF into separate files and names the files after a text string it finds in the PDF.
I've tried to 'join' them to make a single script (or Automator Workflow, but I'm no good at scripting!
Can anyone help?
The first script to convert Word is called via Automator - "Ask for Finder Items":
property theList : {"doc", "docx"}
on run {input, parameters}
set output to {}
tell application "Microsoft Word" to set theOldDefaultPath to get default file path file path type documents path
repeat with x in input
try
set theDoc to contents of x
tell application "Finder"
set theFilePath to container of theDoc as text
set ext to name extension of theDoc
if ext is in theList then
set theName to name of theDoc
copy length of theName to l
copy length of ext to exl
set n to l - exl - 1
copy characters 1 through n of theName as string to theFilename
set theFilename to theFilename & ".pdf"
tell application "Microsoft Word"
set default file path file path type documents path path theFilePath
open theDoc
set theActiveDoc to the active document
save as theActiveDoc file format format PDF file name theFilename
copy (POSIX path of (theFilePath & theFilename as string)) to end of output
close theActiveDoc
end tell
end if
end tell
end try
end repeat
tell application "Microsoft Word" to set default file path file path type documents path path theOldDefaultPath
return output
end run
The second script asks for PDFs and searches for a string beginning "Number: " and uses that string to write single PDFs:
_main()
on _main()
script o
property aa : choose file with prompt ("Choose PDF Files.") of type {"com.adobe.pdf"} ¬
default location (path to desktop) with multiple selections allowed
set my aa's beginning to choose folder with prompt ("Choose Destination Folder.") ¬
default location (path to desktop)
set args to ""
repeat with a in my aa
set args to args & a's POSIX path's quoted form & space
end repeat
considering numeric strings
if (system info)'s system version < "10.9" then
set ruby to "/usr/bin/ruby"
else
set ruby to "/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby"
end if
end considering
do shell script ruby & " <<'EOF' - " & args & "
require 'osx/cocoa'
include OSX
require_framework 'PDFKit'
outdir = ARGV.shift.chomp('/')
ARGV.select {|f| f =~ /\\.pdf$/i }.each do |f|
url = NSURL.fileURLWithPath(f)
doc = PDFDocument.alloc.initWithURL(url)
path = doc.documentURL.path
pcnt = doc.pageCount
(0 .. (pcnt - 1)).each do |i|
page = doc.pageAtIndex(i)
page.string.to_s =~ /Number: \\S*/
name = $&
unless name
puts \"no matching string in page #{i + 1} of #{path}\"
next # ignore this page
end
newname = name[8..-1]
doc1 = PDFDocument.alloc.initWithData(page.dataRepresentation) # doc for this page
unless doc1.writeToFile(\"#{outdir}/#{newname}.pdf\")
puts \"failed to save page #{i + 1} of #{path}\"
end
end
end
EOF"
end script
tell o to run
end _main
Is it even possible to convert these 2 scripts into a single one?
copy length of theName to l
copy length of ext to exl
close theActiveDoc
end tell
Hello
You may combine the second script with the Run AppleScript action converting doc/docx to pdf by creating a Run AppleScript action with the following code that receives a list of POSIX path of pdf files from the previous action and put the action after the previous action in workflow.
Since the previous action returns list of POSIX path of pdf files, _main() in the second script is modified accordingly.
The resulting workflow would consist of three actions:
1) Ask for Finder Items
2) Run AppleScript (to convert doc/docx to pdf)
3) Run AppleScript (the following code)
on run {input, parameters}
_main(input)
end run
on _main(argv)
list argv : list of POSIX path of pdf files
script o
property aa : choose file with prompt ("Choose PDF Files.") of type {"com.adobe.pdf"} ¬
default location (path to desktop) with multiple selections allowed
set my aa's beginning to choose folder with prompt ("Choose Destination Folder.") ¬
default location (path to desktop)
set args to ""
repeat with a in my aa
set args to args & a's POSIX path's quoted form & space
end repeat
property aa : argv
set my aa's beginning to (choose folder with prompt ("Choose Destination Folder.") ¬
default location (path to desktop))'s POSIX path
set args to ""
repeat with a in my aa
set args to args & a's quoted form & space
end repeat
considering numeric strings
if (system info)'s system version < "10.9" then
set ruby to "/usr/bin/ruby"
else
set ruby to "/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby"
end if
end considering
do shell script ruby & " <<'EOF' - " & args & "
require 'osx/cocoa'
include OSX
require_framework 'PDFKit'
outdir = ARGV.shift.chomp('/')
ARGV.select {|f| f =~ /\\.pdf$/i }.each do |f|
url = NSURL.fileURLWithPath(f)
doc = PDFDocument.alloc.initWithURL(url)
path = doc.documentURL.path
pcnt = doc.pageCount
(0 .. (pcnt - 1)).each do |i|
page = doc.pageAtIndex(i)
page.string.to_s =~ /Number: \\S*/
name = $&
unless name
puts \"no matching string in page #{i + 1} of #{path}\"
next # ignore this page
end
newname = name[8..-1]
doc1 = PDFDocument.alloc.initWithData(page.dataRepresentation) # doc for this page
unless doc1.writeToFile(\"#{outdir}/#{newname}.pdf\")
puts \"failed to save page #{i + 1} of #{path}\"
end
end
end
EOF"
end script
tell o to run
end _main
* Of course, actions 2) and 3) can be merged into one action. Or even all 3 actions can be merged into one. But I think a workflow with 3 separate actions is just fine.
Hope this may help,
H
Similar Messages
-
How to pass the result of one script to another?
Hi
Is there any possibility to pass info from one script to another? I run some scripts at night and they have to use the results I get during the day...
Thank you in advance for any help
VeraThere's a couple of ways of doing this.
It sounds like the second script isn't being called directly from the first one, so you can't pass the data directly, so that leaves you with a couple of options.
One is to have the first script write the data to a file, then have the second script read that file.
The other would be to store the data as a property in the first script - properties are saved between executions - then have the second script read the first script's property when it starts up.
For the first option, just have the script write the data to a file:
set myData to "here's the data to save"
set myFile to (open for access file (path to home folder as text & "data.file") with write permission
write myData to myFile starting at 0
close access myFile
Now the second script can read the file:
set otherScriptsData to read file (path to home folder as text & "data.file")
For the second option, just store the data as a property:
property myData:""
set myData to "here's the data to save"
Now loading the data in the second script goes like:
set otherScript to load script file "path:to:other.scpt"
set otherScriptsData to otherScript's myData
Here you can see the second script loading the script then reading its myData property. -
OBIEE 11g How to pass variable from one prompt to another prompt in dashboard page.
How to pass variable from one prompt to another prompt in dashboard page.
I have two prompt in dashboard page as below.
Reporttype
prompt: values(Accounting, Operational) Note: values stored as
presentation variable and they are not coming from table.
Date prompt values (Account_date, Operation_date)
Note:values are coming from dim_date table.
Now the task is When user select First
Prompt value “Accounting” Then in the
second prompt should display only Accounting_dates , if user select “operational”
and it should display only operation_dates in second prompt.
In order to solve this issue I made the
first prompt “Reporttype” values(Accounting, Operational) as presentation
values (custom specific values) and default presentation value is accounting.
In second prompt Date are coming from
dim_date table and I selected Sql results as shown below.
SELECT case when '@{Reporttype}'='Accounting'
then "Dates (Receipts)"."Acct Year"
else "Dates (Receipts)"."Ops
Year" End FROM "Receipts"
Issue: Presentation variable value is not
changing in sql when user select “operation” and second prompt always shows
acct year in second prompt.
For testing pupose I kept this presentation
variable in text object of dashboard and values are changing there, but not in
second prompt sql.
Please suggest the solution.You will want to use the MoveClipLoader class (using its loadClip() and addListener() methods) rather than loadMovie so that you can wait for the file to load before you try to access anything in it. You can create an empty movieclip to load the swf into, and in that way the loaded file can be targeted using the empty movieclip instance name.
-
HT201250 how can i pass information from one mac to another mac by using the time capsule
how can i pass information from one mac to another mac by using the time capsule
If you want to transfer files, settings, etc., you must open Migration Assistant (Applications > Utilities) in the Mac that you want to transfer the files and follow the instructions
-
How can i pass the value one from to another form?
hi all
how can i pass the value one from to another form with out use it when ever i want to needed this value that ican useit?
like i have two fields U_test1 and U_test2 table name @AUSR
that i have four form A! , A2,A3,A4 please tell me in details....?Hi,
U can assign the values to some variables and access then in ur required forms.
Vasu Natari. -
Passing data from one frame to another frame
hello all, i am having a problem with passing data from one frame from another. I have a main frame when you click on connect button it display the second frame(class) that has 2 text fields and 2 buttons. When i click on connect it check if the data is correct. If the data is correct i want that frame to close and pass the data back to main frame. How can i do that.
thank youhello all, i am having a problem with passing data
from one frame from another. I have a main frame when
you click on connect button it display the second
frame(class) that has 2 text fields and 2 buttons.
When i click on connect it check if the data is
correct. If the data is correct i want that frame to
close and pass the data back to main frame. How can
i do that.
thank you
the original problem sounded like an ideal opportunity to use Modal Dialog. if you want one frame to display another to get user input then you need to stop the method in the main frame from executing until you recieve a valid input.
you can use your own class and keep all of the components that you have in the connect frame but you would have to extend JDialog instead of JFrame.
there is a way around it!
if you must use JFrame for both, then you need to have access to the main frame in the connect frame, maybe pass the pointer to the constructor??
anyway, when the connect frame is done with its duties, you have to use the pointer to call another method in the main frame that will continue the process. otherwise main frame doesn't know when connect frame is done and by that time, the method in main frame that instantiated the connect frame has long since died.
also, it allows things to happen in the other window that you may not want to happen until the connect frame is done
typically users of software start clicking around on things and you could have three or four connect frames going at the same time
it's really best to use a Modal Dialog, it really can look just like a JFrame!!!!!!!!!!!!!! -
Hi All,
I am new to TestStand. Still in the process of learning it.
What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?
Thanks in advance,
LaVIEWan
Solved!
Go to Solution.Hi,
Using the Parameters is the correct method to pass data into and out of a sub sequence. You assign your data to be passed into or out of a Sequence when you are in the Edit Sequence Call dialog and in the Sequence Parameter list.
Regards
Ray Farmer -
Passing Variables from one View to another
First of all Hi this is my first post on the sap forums.
Aplogies if I have come to the wrong place or if this question is very easy, but I am new to abap and web dynpro and have found myself struggling a little bit. So I stumbled across this site and thought I would ask for help.
My problem is this, I have 2 variables on my MAIN view, one called MONTH and the other called YEAR. What I want to do is on a button click on the MAIN view pass the values of these variables to another view called SUMMARY_RPT and then use these variables in an SQL query I have on this view.
Anybody out there that can help ?
Many Thanks,
GeorgeHi George,
Welcome to webdynpro abap community. To pass data from one view to another, you can should create two attributes (type string) in the attribute tab of of the component controller. Now these will act as global variable for you. Now you can access these attribute in your view in this way:
wd_comp_controller->gv_val "gv_val is the name of the attribute
Populate the value in it and use it anywhere you want.
There is one more way to do the same.
Create a node under context in component controller and create 2 attributes(type string) after that. Map this node to both the views. Now get the value of month , year and set these attribute with the same values with the help of code wizard in view 1. Now in the view2 simply read those attribute and you'll get the value of month and year which was entered in the first view. Read the attribute with the help of code wizard. Now you can use them accordingly.
I would suggest you to use 1st method as it is better performance wise.
I hope it helps.
Regards
Arjun -
Passing Tables from one method to another method.
Hi All,
I'm creating a Web-Dynpro program in which I wouild like to passing an internal table from one method to another method within the same View.
Is this possible? And if so, how can I set it up.
Thank you.
PaulHi Paul ,
I hope u wud be clear with passing table from one method to another now .U may also wish to see this WIKI
Link: [Passing table parameters|https://wiki.sdn.sap.com/wiki/display/WDABAP/Passingtableparameterfromoneviewtoanotherview+locally]
I hope it wud help u .
regards,
amit -
Passing items from one tab to another
Hi there,
I have two reports, each on a seperate tab, I would like to pass values from one tab to another, anybody know how I can achieve this. Thanks...
Edited by: user9129179 on 10-Mar-2010 04:21Ahh, I see - thanks for clarifying.
I think in that case it would be easier simply to reference the value of the item on the other page instead of pushing the value to the target page.
e.g. on page 100...
:P100_SOME_ITEM := :P200_SOME_ITEM; -- Read value from Page 200Would that work for you?
Additional:
Editing the item on the target page, under the Source section:
- Source Used = Always, replacing any existing value in session state
- Source Type = Item (application or page item name)
- Source Value = <name of item on source tab>
Edited by: FFS on 10-Mar-2010 07:35 -
Passing variables from one swf to another
I am facing problem to pass variable from one swf to another.
I am using loadMovie to load another swf. how can I pass a variable
value to another swf. Can anyone help me plz? It is somewhat
urgent.
thanx in advance.first of all:
this is the Flash Media Server and your problem is not
related to FMS....
second thing related to the "somewhat urgent" :
we, users on this forum, are not there to do your job... so
calm down otherwise no people will answer your question. This forum
is a free support forum that community of Flash developer use to
learn tricks and to solve problems.
Possibles solutions:
If the two swf are seperate you can use LocalConnection to
establish a connection between different swf.
If you load a second swf into the first one you can interact
like a standard movieClip(only if there from the same domain or if
you a policy file on the other server)
You can use SetVariable(via Javascript) to modify a root
variable on the other swf and check with an _root.onEnterFrame to
see if the variable had changed in the second swf.
* MovieClipLoader will do a better job, in your specify case,
than the loadMovie. Use the onLoadInit event to see when the swf is
really totaly loaded into the first one otherwise you will have
timing issues.
My final answer(lol) is the solution 2 with the
notice(*) -
Passing value from one jsp to another?
how to pass value from one jsp to another? i have a value assigned in the link, i want to pass that value to another jsp page?
please help with code?Instead of the value being passed, i am getting a null value.
Here is my calendar code:
<%@page import="java.util.*,java.text.*" %>
<html>
<head>
<title>Print a month page.</title>
</head>
<body bgcolor="white">
<%
boolean yyok = false;
int yy = 0, mm = 0;
String yyString = request.getParameter("year");
if (yyString != null && yyString.length() > 0)
try
yy = Integer.parseInt(yyString);
yyok = true;
catch (NumberFormatException e)
out.println("Year " + yyString + " invalid" );
Calendar c = Calendar.getInstance( );
if (!yyok)yy = c.get(Calendar.YEAR);
mm = c.get(Calendar.MONTH);
%>
<table align="center">
<tr>
<td>
<form method=post action="calendar.jsp">
Enter Year : <select name="year">
<%
for(int i= yy;i<=2010;i++)
%>
<OPTION VALUE= <%=i%> > <%=i%> </option>
<%
%>
</select>
<input type=submit value="Display">
</form>
</td>
</tr>
<tr>
<table>
<%!
String[] months = {"January","February","March",
"April","May","June",
"July","August","September",
"October","November", "December"
int dom[] = {
31, 28, 31, 30,
31, 30, 31, 31,
30, 31, 30, 31
%>
<%
int leadGap =0;
%>
<div id="t1" class="tip"><table border="4" cellpadding=3 cellspacing="3" width="250" align="center" bgcolor="lavender">
<tr>
<td halign="centre" colgroup span="7" style="color:#FF0000;">
</colgroup>
<tr>
<td>
<%
GregorianCalendar calendar =null;
for(int j=0;j<12;j++)
calendar = new GregorianCalendar(yy, j, 1);
int row = 1 ;
row = row + j;
%>
<table>
<tr>
<colgroup span="7" style="color:#FF0000;">
</colgroup>
</tr>
<tr align="center">
<th colspan=7>
<%= months[j] %>
<%= yy %>
</th>
</tr>
<tr>
<td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td>
</tr>
<%
leadGap = calendar.get(Calendar.DAY_OF_WEEK)-1;
int daysInMonth = dom[j];
if ( calendar.isLeapYear( calendar.get(Calendar.YEAR) ) && j == 1)
++daysInMonth;
out.print("<tr>");
out.print(" ");
for (int h = 0; h < leadGap; h++)
out.print("<td>");
out.print("</td>");
for (int h = 1; h <= daysInMonth; h++)
out.print("<td>");
out.print("<a href=desc.jsp>" + h + "</a>" );
out.print("</td>");
if ((leadGap + h) % 7 == 0)
out.println("</tr>");
out.println("</tr></table></div>");
if( row%3 != 0)
out.println("</td><td>");
else
out.println("</td></tr>\n<tr><td>");
%>
</html>I need to pass the value in 'h' to the desc.jsp page.
my code for desc.jsp is :
<html>
<head>
</head>
<body bgcolor="lightblue">
<form method=post action="Calenda.jsp">
<br>
<%= request.getParameter("h") %>
<h2> Description of the event <INPUT NAME="description" TYPE=TEXT SIZE=20> </h2>
<BR> <INPUT TYPE=SUBMIT VALUE="submit">
</form>
</body>
</html>But i am not able to pass the value. The 'h' value contains all the date. i want to pass only a single date, the user clicks to the other page. please help -
Passing paremeters from one page to another
Hi,
I want to pass parameters from one page to another page. On the first page, I
have a form portlet based on scott.dept and one the second page I have another
form portlet based on scott.emp. Now I intend to pass deptno as parameter to
get the detailed info on the other page.
Any help would be highly appreciated.
ThanksSearching in these forums will answer most of your questions
please see :-
Select permissions for different schemas
Re: PL/SQL Tuning Issues
Where I can get Dealership for sale of Oracle E-Business Suite 11i -
Getting error , while passing parameters from one page to another page
Hello friends,
i am getting error, while passing parameters from one page to another page, below code i wrote.
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
ArrayList arl=new ArrayList();
EresFrameworkAMImpl am=(EresFrameworkAMImpl)pageContext.getApplicationModule(webBean);
ERecordImpl ERecordObj=new ERecordImpl();
HashMap hMap = new HashMap();
hMap.put("1",ERecordObj.getTransactionName());
hMap.put("2",ERecordObj.getTransactionKey());
hMap.put("3",ERecordObj.getDeferredMode());
hMap.put("4",ERecordObj.getUserKeyLabel());
hMap.put("5",ERecordObj.getUserKeyValue());
hMap.put("6",ERecordObj.getTransactionAuditId());
hMap.put("7",ERecordObj.getRequester());
hMap.put("8",ERecordObj.getSourceApplication());
hMap.put("9",ERecordObj.getPostOpAPI());
hMap.put("10",ERecordObj.getPayload());
// hMap.put(EresConstants.ERES_PROCESS_ID,
if(pageContext.getParameter("item1")!=null)
pageContext.forwardImmediately(EresConstants.EINITIALS_FUNCTION,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
hMap,
true,
OAWebBeanConstants.ADD_BREAD_CRUMB_YES
Error(71,2): method forwardImmediately(java.lang.String, byte, null, java.util.HashMap, boolean, java.lang.String) not found in interface oracle.apps.fnd.framework.webui.OAPageContext
Thanks
krishna.Hi,
You have imported the wrong class for HashMap.
Import
com.sun.java.util.collections.HashMap; instead of java.util.HashMap
Thanks,
Gaurav -
Is there any way to pass value from one SWF to another ?
I am doing project using flash, now I cant pass a value from one SWF to another, is there any way to pass value from one SWF to another.
thanksHi,
Just to confirm here do you simply want to communicate between two SWFs without involving Flash Media Server. If this is the case one good way of doing it is to use a local connection. It can be used for direct communication between two separate instances of the flash player. However if you want to involve multiple clients sharing a common variable then you may have to use Shared Object for this. Please let me know what is the actual use case, is it multiple clients sharing a common variable or different player instances communicating between themselves.
Thanks,
Abhishek
Maybe you are looking for
-
DataGrid scrollbar on left side.
I know I have seen a topic about this somewhere but this forum has such a bad searchfunction that I cant find the answer... I have 2 DataGrids, 1 must have the vertical scrollbar on the right side (normal), and 1 must have the vertical scrollbar on t
-
Final Cut Pro keeps quitting on me!!
As I'm trying to import an audio track from a CD into Final Cut, the program 'unexpectedly quits'. How do I import music for Final Cut to stopping shutting down on me?!?
-
Microsoft manner, locking us to .Mac
The new "features" in iPhoto shows a scary road towards forcing users to stay within the Apple frame. It wasnt like that. It used to be Open and standards complience. .Mac is just as irritating now as MSN. Now we cant export as webpage anymore, with
-
Result of XML fields cannot be bold?
Hi all, When i load XML data in my RTF file the output result of some fields are not bold. I check the RTF and every field i want in BOLD is clicked to be bold. How is this possible? Thanks in advance, Konska.
-
Reports of service / material purchase orders
Hi, in my firm receipt of services is done in tcode ML81N and receipt of material is done in tcode MIGO is it possible to extract a report of all purchase orders of services, i.e. purchase orders that were received through ML81N, and a report of all