Loop through all open documents not performing some actions
I have a loop that imports XML, then Exports each page individually, then has a SaveAs dialog for the indd, then closes the active document.
The import XML works, the SaveAs works, and the close works but the loop skips over the PDF part. Is it because I need to define myCounter in the for loop within the ExportPDF function? I just included the part from Choose XML to the end of ExportPDF.
//choose XML
var FilterXML = "XML File: *.xml";
var myXML = File.openDialog("Choose XML File", FilterXML);
//loop for each action below
for(myDocumentCounter = app.documents.length; myDocumentCounter > 0; myDocumentCounter--){
//import XML
app.activeDocument.importXML(myXML);
//PDF by page to settings; preset must be "dailies_x1a"
function myExportPages(myFolder){
var myPageName, myFilePath, myFile;
var myDocument = app.activeDocument;
var myDocumentName = myDocument.name;
var myBaseName = myBaseNameField.editContents;
for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
myPageName = myDocument.pages.item(myCounter).name;
app.pdfExportPreferences.pageRange = myPageName;
//The name of the exported files will be the base name + the page name + ".pdf".
//If the page name contains a colon (as it will if the document contains sections), then remove the colon.
var myRegExp = new RegExp(":","gi");
myPageName = myPageName.replace(myRegExp, "_");
myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + ".pdf";
myFile = new File(myFilePath);
myDocument.exportFile(ExportFormat.pdfType, myFile, false, "dailies_x1a");
Nevermind, I found my error. Code should read...
for(myDocumentCounter = app.documents.length; myDocumentCounter > 0; myDocumentCounter--){
if(app.documents.length != 0){
var myFolder = Folder.selectDialog ("Choose a Folder to Save the PDFs");
if(myFolder != null){
myExportPages(myFolder);
else{
alert("Please open a document and try again.");
function myExportPages(myFolder){
var myPageName, myFilePath, myFile;
var myDocument = app.activeDocument;
var myDocumentName = myDocument.name;
var myDialog = app.dialogs.add();
with(myDialog.dialogColumns.add().dialogRows.add()){
staticTexts.add({staticLabel:"Please Modify the Base Name if Necissary:"});
var myBaseNameField = textEditboxes.add({editContents:myDocumentName,
minWidth:160});
var myResult = myDialog.show({name:"ExportPages"});
if(myResult == true){
var myBaseName = myBaseNameField.editContents;
//Remove the dialog box from memory.
myDialog.destroy();
for(var myCounter = 0; myCounter < myDocument.pages.length;
myCounter++){
myPageName = myDocument.pages.item(myCounter).name;
app.pdfExportPreferences.pageRange = myPageName;
//The name of the exported files will be the base name + the
//page name + ".pdf".
//If the page name contains a colon (as it will if the
//document contains sections),
//then remove the colon.
var myRegExp = new RegExp(":","gi");
myPageName = myPageName.replace(myRegExp, "_");
myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + ".pdf";
myFile = new File(myFilePath);
myDocument.exportFile(ExportFormat.pdfType, myFile, false, "dailies_x1a");
else{
myDialog.destroy();
Similar Messages
-
Hi,
I'm making a batch processing action and I really need a script that iterates through all open documents, finds the one with the biggest image size and then iterates one more time to change the rest of the documents to the same image size dimensions. At the end all documents must share identical image size. I'll really appreciate if someone can put a quick script for doing this. Thank you !I think should do…
#target photoshop
if (documents.length > 1) {
var smallest = 1000000; // Set beyond any size you may be expecting this should do?
for (var a = 0; a < documents.length; a++) {
smallest = Math.min(smallest,documents[a].width.as('px'));
for (var b = 0; b < documents.length; b++) {
if (documents[b].width.as('px') != smallest) {
app.activeDocument = documents[b];
var newWidth = new UnitValue(smallest, 'px');
documents[b].resizeImage(newWidth,undefined,undefined,ResampleMethod.BICUBICSMOOTHER);
}else{
alert("NOT enough docs to resize?"); -
How do i tab through all open documents
Alt + Tab on a windows machine will tab through all open windows and documents. Command + Tab on my IMAC will only tab through the open applications. Is there a way I can set up the IMAC to work like to windows machine in this case?
four finger swipe upwards will show you everything thats open. its not the same as on a pc where it shows each program in a rotating type of display... but it does show each program and the windows within that program that are open.
-
How to get all open document?
I want to replace some elements through all open documents in
dreamweaver.
eg. replace <b> to <strong> and </b> to
</strong>
I know i can do this by using "replacing all", but i want to
replace a lot of things together. it's boring to replace them one
by one :P
Anyone know how to make it?
Thank you for your help! ^^"xsiren" <[email protected]> wrote in
message
news:f1v1o5$333$[email protected]..
> the "dreamweaver.getDocumentList()" is only for get all
the list of open
> documens, istn't it?
> i tried to alert the value of it, and it show something
like
> "file://D:\develop\1.html" "file://D:\develop\2.html"
And then you are supposed to get the DOM out of the url,
passing it as an
argument to dreamweaver.getDocumentDOM()
Massimo Foti, web-programmer for hire
Tools for ColdFusion and Dreamweaver developers:
http://www.massimocorner.com -
Loop through all controls in view
Hi Everyone,
I need to cycle through all the controls on a view.
I have set each of the controls of type UISegmentedControl with a unique tag number.
I am using this tag number to perform a lookup in database for the value of the segmented control.
So, my question is this.... how do i cycle through all the controls on a view?
thank you
take care
tonyalt-088 wrote:
I think we are close - just one correction.
The segmented controls are all at design time, there will be no new controls added.
I'm not clear on what's been corrected. The sample code I gave you assumed all the controls were known at compile time. So I think the example code addressed the problem you're trying to solve. The last paragraph of that post was just an afterthought, to explain what to do in case you ever needed to add controls dynamically.
-> loop through all controls on view
-> if control is of type uisegmentdcontrol
then do database lookup on tag
Set segment value to value returned from database
Once again, if I correctly understand the above, the code I gave you does exactly what you want. You haven't indicated you want to take any action when a control is not a segmented control, so I don't see why you'd want to include them in the loop. However, if you actually do need to enumerate non-segmented controls (or other subviews), my last response advised you to set the tag properties of all those other controls, making sure the range of those tags is different from the range of the seg control tags.
The part that eludes me is the looping through all the controls on the view
I guess the part that eludes me is why you're so interested in enumerating all the controls, when you only seem to be interested in the segmented controls. But even if you really do need to look at every control, I don't see why you're rejecting the solution I gave you. [viewWithTag:|http://developer.apple.com/iphone/library/documentation/UIKit/Ref erence/UIViewClass/UIView/UIView.html#//appleref/doc/uid/TP40006816-CH3-SW26] is a powerful method which recursively walks the entire view hierarchy to find whatever tag it's looking for. If you use it correctly (e.g. by assigning unique tag numbers that tell you what type of control you've found), it will save you lots of trouble.
If, for some reason, you insist on doing this job without using viewWithTag, the next best might be something like this:
- (void)doSomethingWithEachSegCtrlInView:(UIView *theView) {
UIView *subView;
for (subView in theView.subviews) {
if ([subView respondsToSelector:@selector(selectedSegmentIndex)]) {
// subView is a segmented control ...
else {
// subView is not a segmented control ...
if ([subView.subviews count]) {
// this subview has its own subviews
[self doSomethingWithEachSegCtrlInView:subView];
Note that the above is a more difficult, more error prone method than the sample in my first response. Firstly, it needs to recurse in case any controls are placed on subviews of the main view (or on subviews of those subviews, etc.), a capability already built into viewWithTag. Secondly it needs to identify the type of each subview object. [respondsToSelector:|http://developer.apple.com/iphone/library/documentation/Co coa/Reference/Foundation/Protocols/NSObjectProtocol/Reference/NSObject.html#//appleref/occ/intfm/NSObject/respondsToSelector:] is the preferred way of identifying the class of an object, especially when the selector argument represents one of the methods you intend to use. However there's no reason to get into the business of identifying the class of an object, when you could have given that object a unique tag number in the xib, where there was no question about its class.
Hope the above communicates the solution better than my first response!
- Ray -
Loop through all fields in a (2 page) form?
Is it possible to do it in one go?
suppose you have fields in 2 pages.. (2 subforms)
would you have to write a script that would check for all fields in page 1
and another to check for all fields in subform 2?
or can you just loop through the parent of the 2 subforms?.. (the aim would be to check that all required fields have been filled in or are not equal to their default value)
thank you in advanceYou can certainly write a script that'll find all fields on all pages and perform some action on them.
I've included a sample form which contains two pages with fields on them. At the top of the first page, there's a "Find Fields" button which, when pressed, populates the list box next to it with the names of each field found across all pages. Clicking on an item in the list box will then set focus to that field.
The script uses a recursive function called GetFieldNames in a Script Object called "Utils". In the function, lines 21 - 25 are as follows:
else if (oNode.className == "field")
// oNode is a field
sFieldNames += (sFieldNames.length > 0 ? "\n" : "") + oNode.name;
If you wanted to verify that all mandatory fields were filled, you could change them to this:
else if (oNode.className == "field")
// oNode is a field
if (oNode.mandatory == "error" && (oNode.rawValue == null || oNode.rawValue.length == 0))
sFieldNames += (sFieldNames.length > 0 ? "\n" : "") + oNode.name;
That would find only fields that are required and haven't been filled accross all pages.
Stefan
Adobe Systems -
How to save all open document in png 24 by javacsript
how to save all open document in png 24 by javacsript
yeah, i can definitely see how it would be useful for some
people! and
hey, for all i know, i'm the one who's not an average user. i
was
pretty much just saying that i can see how that's something
Firefox
would think to do, but not necessarily a program like
Dreamweaver. but i
agree that it would be a useful feature in lots of programs.
and i think
that what Murray suggested is probably pretty close to what
you're
looking for, if not exactly.
d_macman wrote:
> To respond to both...
>
> courtney (n h c)... I must not be the average user then.
We have many sites,
> and I do a LOT of development, and many times, I may
have several pages with
> several includes on a page. IE, for a form page, I may
have 10-12 pages total
> (including headers, footers, java, PHP process pages,
etc) and to work out the
> processes and for development, I may create several
versions depending on the
> problems I run into.So to not go nuts, I would LOVE to
save the batch of pages
> out, and then be able to re-open them all at once.
Making it easy to jump in an
> out of a test section (I have them saved in a site, and
dont want to make
> second sites just for this purpose).
>
> Not to mention, leaving work and coming back in and
finding out the power went
> out over the weekend and my machine shutdown (and yes, I
have a UPS, but it
> wont run the system for that long).
>
> So, you see why I would like to save them as batch, like
Firefox, way easier.
>
> Murray *ACE* ...
>
> I will try that, I did not even know that was there. Way
cool ! I hope it
> works, especially for power outages, like I mentioned
above!
>
> Thanks all,
>
> Don
>
> -
Applescript to save all open documents?
Hello,
When I close Numbers, I usually have about 15 documents with changes and I have to go through "Do you want to save changes" for all of them.
I've googled and tried, without success, to get a script that saves all open documents, except for untitled ones.
Is there anyone who know such a script?
FredHere is a revised version.
The problem was due to the fact that the script save and close the documents.
When I tested it, it was only saving them.
--[SCRIPT save&backup4iWork]
Enregistrer le script en tant que Script : save&zip4iWork.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:
Aller au menu Scripts puis choisir “save&zip4iWork”
Tous les documents iWork ouverts, ayant déjà été enregistrés puis modifiés seront enregistrés et fermés.
Si la propriété avecSauvegarde a la valeur true, une copie horodatée de chaque fichier est créée.
Si le document principal est de type paquet, la copie est compressée (zip).
--=====
L’aide du Finder explique:
L’Utilitaire AppleScript permet d’activer le Menu des scripts :
Ouvrez l’Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case “Afficher le menu des scripts dans la barre de menus”.
Sous 10.6.x,
aller dans le panneau “Général” du dialogue Préférences de l’Éditeur Applescript
puis cocher la case “Afficher le menu des scripts dans la barre des menus”.
--=====
Save the script as a Script: save&zip4iWork.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Go to the Scripts Menu then choose “save&zip4iWork”
Every open iWork document already saved then edited will be saved and closed.
--=====
The Finder’s Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the “Show Script Menu in menu bar” checkbox.
Under 10.6.x,
go to the General panel of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
if the property avecSauvegarde is set to true, a dateTime stamped copy of each document is also created.
It's zipped if the main document is a package.
Yvan KOENIG
based on my AutoSave script.
2011/06/09
--=====
property avecSauvegarde : false
true = keep a dateTime stamped copy
false = don't keep a dateTime stamped copy
property saveKeynote : false
property saveNumbers : true
property savePages : false
--=====
on run
if savePages then my auto4PKN("Pages")
if saveKeynote then my auto4PKN("Keynote")
if saveNumbers then my auto4PKN("Numbers")
end run
--=====
on auto4PKN(theApp)
local titres, theDocs, aDoc, aPath
tell application "System Events" to set titres to title of processes
if theApp is in titres then
tell application theApp
As we close the documents, we must store the list of docs in a variable
or scan the list from the end which would require an index !
set theDocs to every document
repeat with aDoc in theDocs
if modified of aDoc then
set aPath to path of aDoc
try
set aPath to aPath as text
on error
Here if the document was never saved before
set aPath to ""
end try
if aPath is not "" then
Save and close documents which were already saved once
close aDoc with saving
if avecSauvegarde then my zipIt(aPath)
end if -- aPath
end if -- modified
end repeat
end tell -- theApp
end if -- theApp is…
end auto4PKN
--=====
on zipIt(fichier) (* fichier is an HFS path*)
local Nom, ext, dossier, isPackage, nomAvecDateHeure, source, dest
set fichier to "" & fichier
tell application "System Events" to tell disk item fichier
set Nom to name
set ext to name extension
set dossier to path of container
set isPackage to package folder
end tell
set source to quoted form of POSIX path of fichier
set nomAvecDateHeure to (text 1 thru -(2 + (count of ext)) of Nom) & (do shell script "date +_%Y%m%d-%H%M%S.") & ext
if isPackage then
set dest to quoted form of POSIX path of (dossier & nomAvecDateHeure & ".zip")
do shell script "ditto -ck " & source & " " & dest
else
set dest to quoted form of POSIX path of (dossier & nomAvecDateHeure)
do shell script "cp " & source & " " & dest
end if
end zipIt
--=====
--[SCRIPT]
--{code}
I included your specific requirements.
Yvan KOENIG (VALLAURIS, France) jeudi 9 juin 2011 18:03:20
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.7
Please : Search for questions similar to your own before submitting them to the community
To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer ! -
Sales document report for all open documents
hi i need the code for sales document report for all open documents is sd
... can anyone help me out.
thanks in advanceTry transaction VA05. In that choose "Open Orders" along with other selection criteria.
If you want the Open sales order qty in output and its not displayed, do the following.
Sales -> System modification -> create new fields ( without condition technique) -> New fields for lists.
You can change V05TZZMO and structure VBMTVZ from there or use SE38 / SE11.
For both you'll need an object registration in OSS.
Hope this helps.
Thanks,
Balaji -
Loop through all layers and sublayers
is there a way that I can loop through all layers and sublayers looking for a name of a layer? I have one that loops through only top level layers. I am thinking I have to somehow incorperate all pathItems, groupItems and the like to incorperate all types of "layers" there might be, since a group is technically not a layer but a groupItem.
this is what I am doing so far:
for (var i = 0; i < numberOfLayers; i++) {
var customName = "div structure";
var myLayer = app.activeDocument.layers[i];
var myLayer = myLayer.name;
alert(myLayer);
//alert (myLayer);
if (customName == myLayer) {
alert("layer matches");
else { break; }
any ideas?Sorry I don't understand what it is you are trying to achieve… Most collections offer a getByName() method if you know what you are looking for eg…
doc.layers.getByName( 'fluff' );
This should return you the first found or error so you need to try & catch when using this… -
Could not perform some final integrity tests
I'm trying to download and install a trial version of Photoshop Elements. Each time the download completes I receive this message, "the download is done but the download manager could not perform some final integrity tests. check the file and download again if necessary"
Can anyone help me overcome this?Try downloading using a different web browser to download.
See this:
http://kb2.adobe.com/cps/152/tn_15296.html
The intergrity error next to last error message in the table points to a download issue. Not exactly the same error but similar...
http://kb2.adobe.com/cps/400/kb400531.html
The above document also states:
Cut/Paste:
Errors not listed in this document
Other error messages may appear when you download files from the Adobe website. These error messages will most likely be generated by your web browser or by your Adobe product installer. -
Run applescript on all open documents
hi all,
I have an applescript that was created to run on the active document. I dont have any applescript abilites but would like to change it to run on all open documents. the script removes all unused master pages and i would like it to run on all opened docs. what do i need to change to make it work?
here is the script....
set moreMasters to {}
tell application "Adobe InDesign CS3"
tell document 1
set allMasters to every master spread
set theMasters to applied master of every page
repeat with x in theMasters
set end of moreMasters to applied master of x
end repeat
set theMasters to theMasters & moreMasters
repeat with x in allMasters
if x is not in theMasters then delete x
end repeat
end tell
end tell
thanks in advance
DanRather than using the numeric index, you can also leave that to AppleScript.
tell application "Adobe InDesign CS4"
repeat with doc in documents
tell doc
set theName to name -- of doc
display dialog theName
end tell
end repeat
end tell -
Looking for PS Script to Save and Close All Open Documents
I used ACR and CS5 to process my Nikon D3 NEF files. I would like a script that would save all open documents (witin PS) with the highest possible quality (12). I've found several scripts that will close all open documents with save but cannot figure out how to implement a save script.
For example, I may have 20 converted .jpeg files open. I would like to run a script to save & close all open documents.
Is it possible? Can someone post an example working script?Take a look at the image processor, under the scripts menu.
MTSTUNER -
Command in Java for "all opened documents"
I have a script that needs modification. Thank you all in the forum for helping me design this script from start btw!
Anyway, this is the script.
var myDoc = app.activeDocument;
app.findGrepPreferences = app.changeGrepPreferences = null;
// Change "Condition 1" to name of your condition
myConditionList = app.activeDocument.conditions.everyItem().getElements();
for (i=myConditionList.length-1; i>=0; i--)
if (myConditionList[i].visible == false)
myConditionList[i].visible = true;
app.findGrepPreferences.appliedConditions = [myConditionList[i].name] ;
app.findGrepPreferences.findWhat = ".+";
myDoc.changeGrep();
app.activeDocument.conditions.item(myConditionList[i].name).remove();
I'm looking for a variable that can apply for "all" opened documents rather than the active one only. I'm having difficulty finding the right command.
BTW, the script removes all hidden text and objects.Programming has never been my strong side. Never understood it properly and probably never will =(. But thank you solving it. The code "JUMO_OVER" wrote, worked like charm. No need to execute the script 10x for 10 documents.
Pardon me for giving you guys more out headaches, I have two additional scripts that needs revision for the same purpose as above, i.e. able to exceute the scrip for all opened docs, saved or unsaved. I would really appreciated if you guys could help me convert them. I tried it do it on my own own, but I can't get it working... =(
Delete Empty Frames in active doc
var myStories = app.activeDocument.stories.everyItem().getElements();
for (i = myStories.length - 1; i >= 0; i--)
var myTextFrames = myStories[i].textContainers;
for (j = myTextFrames.length - 1; j >= 0; j--)
if (myTextFrames[j].contents == "")
myTextFrames[j].remove();
Delete Empty Pages in active doc
app.doScript("main()", ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT,"Remove Blank Pages");
function main () {
if (app.documents.length === 0) {
alert ("Please open a document.");
return;
app.scriptPreferences.enableRedraw = false;
removeBlankPages (app.Documents);
app.scriptPreferences.enableRedraw = true;
function removeBlankPages (doc) {
var pages = doc.pages.everyItem().getElements().slice(0);
var i = pages.length;
while (i-- >1) { // a bit quicker here
!pages[i].allPageItems.length && pages[i].remove ();
!pages[i].allPageItems.length && pages[i] != doc.pages[-1] && pages[i].remove ()
BTW, I didn't write them. So they may look quirky in your eyes. -
When i cancelled the billing doc through VF11 Fi document not yet creted.
Pls help on this issue.
When i cancelled the billing doc through VF11 Fi document not yet creted. system thrown the given below error:
Diagnosis : The document does not exist. It was possibly not posted and therefore cannot be read from the database.
Procedure :
Repeat the transaction at a later time.
Pls help on this issue.I assign full marks .
Rgds
MaheshDear Mahesh
This is bcoz you have not assigned the Accounting Document type for your cancellation billing document.
Go to VOFA, select the cancel billing document type S1 and [see whether S1 is maintained] against the field [Document Type] Most probably, in your case, it is not maintained and hence the problem.
Maintain S1 in the above field and retry to cancel the billing document.
thanks
G. Lakshmipathi
Maybe you are looking for
-
Can someone give me the SQL statement to show if there are any blocking database locks and if so - which user is locking the Database? Thanks in Advance
-
Non-button text not showing up in menu
Is it normal for text in a Blu-ray menu that is not a button to not show up in the menu once it is on a disc or disc image? This is the last issue I am having. I have some text on a menu that is just text. I have had plain text in the past work perfe
-
Running a db2 command from Java Application ??
Hi All, I have to write an application in JDBC that can retrieve a list of databases on a db2 server, the only way I know is the db2 command "list database directory", but I can not use it in a JAVA program, is there a solution for this? Can anyone h
-
Deploytool could not load my class files
Hi, believe me I have searched half of the web and I hope some of this forum could help me now. I have created three class-Files for a Session Bean I want to create for my Application. First I created a new Application in the forlder c:\workspace\fs
-
Update Alert Command in SP 2013
Invoke-AlertFixup Why invoke alert fix up (which is replacement in PowerShell for the stsadm update alert in sp 2007) is not coming up in the SharePoint PowerShell command console, is it custom PowerShell command or any other command we have for upda