Change the case on several documents

Hello!

I'm very new to scripting, and I have the following script that is "Upper" text and change for real uppercase. I work with ID CS 6 on Windows XP.

The script works on a single document, if there is an open, if not, it asks for a file and process all INDD files in this folder.

That's what I have:

if(app.documents.length != 0){
    processDocument(app.activeDocument);
    alert("Done!");
    }
else {
    _folder = Folder('~/Desktop').selectDlg("Select folder");
    if(_folder == null) exit();
    _files = _folder.getFiles("*.indd");
    if(_files.length == 0){
            alert("No INDD files in the selected folder!");            
        }
    else {
        for (i=0; i<_files.length; i++){
        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
        _inddFile = _files[i]
        doc = app.open(_inddFile);
        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;      
        processDocument(doc);
        app.activeDocument.close(SaveOptions.yes);
        } 
    alert("Done!");
    }
}

function processDocument(doc) {    
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.capitalization = Capitalization.allCaps;
    app.findGrepPreferences.appliedCharacterStyle = 'Red';
    var _results = doc.findGrep();
    app.findGrepPreferences = app.changeGrepPreferences = null;    
    _length = _results.length;
    for (i=0; i<_length; i++) {
        _results[i].texts[0].changecase(ChangecaseMode.uppercase);
        _results[i].texts[0].capitalization = Capitalization.normal;
        _results[i].texts[0].appliedCharacterStyle = 'Blue';
    }
}

The script works well on a single document, but for some reason any that it does not work on several documents. I try the script on 4 files with this content (the colors are added in the text only to help verify the results):

Whenever the first or the first two documents are processed correctly, the others are not processed at all. But I get no error message. Where is the problem?

Any help would be greatly appreciated!

Luca

I tried to recreate your problem once again and I don't have something similar. I know it's not normal, but mine started when I changed the variable i in the second. I see that they have a different scope, but somehow she made the difference. Could you try it by chance?

#target indesign
if(app.documents.length != 0){
    processDocument();
    alert("Done!");
    }
else {
    _folder = Folder('~/Desktop').selectDlg("Select folder");
    if(_folder == null) exit();
    _files = _folder.getFiles("*.indd");
    if(_files.length == 0){
            alert("No INDD files in the selected folder!");
        }
    else {
        for (i=0; i<_files.length; i++){
        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
        _inddFile = _files[i] ;
        doc = app.open(_inddFile);
        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
        processDocument(doc);
        app.activeDocument.close(SaveOptions.yes);
        }
    alert("Done!");
    }
} 

function processDocument() {
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.capitalization = Capitalization.allCaps;
    app.findGrepPreferences.appliedCharacterStyle = "Red";
    var _results = app.activeDocument.findGrep();
    $.write(_results);
    app.findGrepPreferences = app.changeGrepPreferences = null;
    _length = _results.length;
    $.write(_length);
    for (s=0; s<_length; s++) {
        _results[s].texts[0].changecase(ChangecaseMode.uppercase);
        _results[s].texts[0].capitalization = Capitalization.normal;
        _results[s].texts[0].appliedCharacterStyle = 'Blue';
    }
}

Tags: InDesign

Similar Questions

  • How to change the extensions on several files with Windows 7?

    * Original title: Extentions

    How to change the extensions on several files with Windows 7?

    You hear no doubt, is that your movie software will only recognize certain types of image file formats.  If this is the case, you will need to reformat format files to any format PNG is recognizable by the software.

    Rather than we guess, please identify your «film» software

    Download and install IrfanView, which is a free utility for images.  http://www.IrfanView.com/

    IrfanView has the ability to read a great many formats of image files.  It can also convert image files formats.  And even better - for you - it can do all these things on a batch of files.

    As test, after I installed IrfanView, open one of your PNG files.  Now click on file > save as, and select the 'Save as Type' to be little matter the file type of your movie software will accept.  Save the file.  Make sure your movie software can accept the new file.

    Once you are convinced that you can modify files that you have in a format that you can use, use IrfanView

    File > Batch Conversion/Rename command.  If necessary, see IrfanView help on this topic.

  • Change the author of several pdf both

    I can easily change the author of a pdf document, but I need to change the author of several pdf and making one is boring.

    Same feature is available in Acrobat X Pro. Before that, you need to use the batch processing tools.

  • RoboHelp is changing the case of my HTML files

    Hello

    RoboHelp is changing the case of my HTML files. File is mixed the original case, but when the file is changed and saved then, RoboHelp changes the name to lowercase. We use X.5.0.2, HTML help, no control of source code and we are not generating (compiling) files. Apparently not an option to make the RoboHelp to stop doing this. If anyone has had this problem and know how to fix?

    Thank you

    -Phil

    I tried the scenario 1 in the document that Phil sent me three files, UPPERCASE. HTM. MixedCase.htm and lowercase.htm.

    In X 5, they are in fact all converted to lowercase. I haven't spotted that before because I tend to work with even when lowercase file names.

    I repeated the test in RH6. While the dialog box telling you which was imported presents all the three files whose names in lowercase, Windows Explorer and the list of topics keeps the case. Looks like a bug that was fixed half! At least, you end up with what you want.

  • Change the location of several pictures at the same time?

    I see how to change the location of a photo at a time. Is it possible to change the location of several pictures at the same time?

    Thank you

    Phil

    Select the photos and info - enter the location (or any other field of the info) and it is applied to all photos

    This is described in using Photos - a good place to get help with Photos

    View and add information about the photos

    To view or change information for the photos, you select one or more photos, and then open the information window.

    • Open the Info window: Double-click a photo to view it, and then click the Info button in the toolbar or press on command I.
    • Add or change information: Change the following.

      • Title: Enter a name in the title field.
      • Description: In the Description field, type a caption.
      • Favorite: Click the Favorites button to mark the photo as a favorite. Click the button again to deselect.
      • Keywords: Enter the keywords in the keywords field. When you type, Photos suggest keywords that you have used before. Press enter when you have finished a keyword. To remove a keyword, select it and press DELETE.
      • Faces: Click on and type a name to identify a face. Click on several times, and then drag the identifier of the face different faces to identify many faces in a photo.
      • Location: Enter a location in the location field. When you type, Photos suggest places you can choose. To change a location, you can search a different location or change the location by dragging a PIN on the map. To remove location information, delete it or choose Image > location, then choose Remove location or back to the original location. You cannot assign a location if your computer is not connected to the Internet.

    LN

  • How to change the default path for documents and settings

    How to change the default path for documents and settings

    I try to change in the registry, but the profile can create but error! had no choice to change the default path % lecteur_systeme % d: /.

    Hello

    I suggest you to download TweakUI, this could help you or get you headed in the right direction
    http://Windows.Microsoft.com/en-us/Windows/downloads/Windows-XP

    Also this KB could help as well:
    http://support.Microsoft.com/kb/236621

    It will be useful.

  • How can I change the case of the police, that is, uppercase, lowercase, in Wordpad?

    I have Wordpad I try to find the icon to change the case of selected text as you can Word. I'm also trying to figure out how to customize the toolbars in Wordpad.

    Can anyone help?

    Sincerely,

    GEGJr

    It does not exist. WordPad is a very basic word processing program. I don't know if that's what you want, but you might want to take a look. It is freeware.
     
  • How can I change the user of "My Documents" by default? »

    I'm changing the user to 'My Documents' which has initially set up a laptop from the MFG.  while I can use it to another employee. I changed the name of the computer, but how do I change the user of "My Documents" by default? »

    Hi W30330,

    Please see the thread with a similar problem and fix possible:

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-system/deleting-old-user-accounts-and/08419300-ef7c-42e5-9027-f123128ebcf8

    I hope this helps!

  • Need to change the default save a document to a card reader in acrobat from adobe pro xi

    We have many users to annotate PDF files, and we need Adobe pro to automatically save the PDF files to a shared drive on the network. So I need to change the default save a document to a card reader in Xi'an of acrobat from adobe pro for everyone.

    Hi sonjab80769668,

    There no such customizable settings in Acrobat Pro XI to make this network as a default location to save the files.

    Kind regards
    Rahul

  • How can I change the name of a document

    not sure how to change the name of a document I have downloaded from the internet. I want to just save a title I'll be able to remember instead of a string of letters and numbers without meaning.

    You can use file > save as in Reader

    Also:

    How to rename a file in Windows

    How to rename files on a Mac

  • How can I change the font in several capacities, at the same time?

    Hey guys, quick question. I have a bunch of titles and of lower thirds in my project and my producer decided that he did not like the police that we used previously and wants to change to a new one. It seems to do quite often. Is there a way to "globally" to change the font of several title cards at the same time instead of clicking on each of them separately and do it manually for each of them? And if there is no way to do that does anyone have any ideas on how to make it easier?

    How to upgrade several titles in Premiere Pro using InDesign

  • Change the properties of several fields

    I need to change the properties of corn (i.e., the number) of several fields when I pass the selection and then right-click, Format tab is not there. Help, please.

    Hi rednexhex,

    It is not possible to change the format of several fields at the same time

    You will need to manually change each field.

    Kind regards

    Rave

  • [JS]: is it all the same to change the name of a document?

    Is anyway to change the name of a document? Or create a document with a certain name?

    I'm looking at the JavaScript reference, and it is said that document.name is a readonly value. It's absolutely true / is there another way to change the name of a document?

    Any help would be appreciated

    Thank you!

    You can change the name of a document in two ways:

    1. open, save under a different name and delete the original.

    2. do not open the document, use the JavaScirpt object file to rename the document. Details are provided in the Guide JavaScript tools, accessed from your ESTK on the Help menu.

    Peter

  • to change the case of text field

    I want to change the case of a text field.

    I use

    _root.createEmptyMovieClip("myTextHolder",1);
    _root.myTextHolder.createTextField("myText",1,0,0,200,30);
    _root.myTextHolder.MyText.text = "this is a new text object";

    How to do?

    reply to your original message, and then view the code you used.

  • Change the font in a document of several pages

    Hello

    I used two fonts in a 80-page document in InDesign and am trying to figure if I can change one of them, if the change is made throughout the entire document?  For example, rather than having to go through each page individually?

    Thanks if anyone can help :-)

    If you set the paragraph styles for your document, simply change the style definitions. Otherwise, type > find font...

Maybe you are looking for

  • Bad - Steely Dan titles "my Rival".

    I tried to listen to "My Rival" by Steely Dan, from the album Gaucho. There was a whole lotta jumping. Then, the next song started before the actual track ends. So weird. Can someone tell me if it is a common problem... Do you feel this error when li

  • Windows Vista not sign out or close

    Windows Vista not sign out or close. Act as if it were in a loop continues.

  • Blackberry10 Webworks / Extension Native Bug (?)

    Someone at - he saw Simulator messages like: Need error can not find /usr/bib/WebPlatform/plugins/mjnext/BP.so Library not found When starting an application of webworks html5 with a native extension. Although I see this error, (1) I know that my arc

  • mass release of zip archives

    I have a bunch of files and archives downloaded from trusted sources. I would like to 'unlock' the content of them to stop the warnings, but let the protection mechanism for untrusted files. Is it possible to unlock everything in a directory or somet

  • Pre-shared blackBerry Smartphones?

    I just got a Curve 8900 and I am trying to set up my wi - fi but I must put in a pre-shared key (PSK) to access. I know my network key but cannot find a pre-shared key. Any help would be much appreciated. Thank you.