Read character 3+4 from filename and move to other position

Hello,
I need a javascript to read my filename (I have the one for the full filename) and especially the 3rd and 4th position of the filename.
The characters on position 3 and 4 must be moved to the position just before the extension.
Example:
4PEN12345.pdf (old name) should be 4P12345_EN.pdf
Now I have the following script to extract all pages in an existing pdf file to separate pages with all the same suffix before the extension
/* Extract Pages to Folder */
    var re = /.*\/|\.pdf$/ig;
    var filename = this.path.replace(re,"");
        for ( var i = 0;  i < this.numPages; i++ )
        this.extractPages
            nStart: i,
            nEnd: i,
            cPath : filename + "_page_" + (i+1) + "_EN.pdf"
Can anybody help me to set me on the right direction?

Now I have the file 4PBG12345-1.pdf (7 pages included in the pdf).
Your script as I filled in:
/* Extract Pages to Folder */
    var re = /.*\/|\.pdf$/ig;
    var filePath = this.path.replace(this.documentFileName, "");
    var oldFileName = this.documentFileName;
    var suffix = oldFileName.substring(2,4);
    var newFileName = oldFileName.substring(0,2) + oldFileName.substring(4).replace(".pdf", "_"+suffix+".pdf");
    var newFilePath = filePath + newFileName;
        for ( var i = 0;  i < this.numPages; i++ )
        this.extractPages
            nStart: i,
            nEnd: i,
            cPath : newFilePath
Result:
1 file ==> 4P12345-1_BG.pdf (7 pages included in the pdf)
Of course, because the syntax for extracting and adding automatic pages is not filled in. So, that was my question, how must I nest to add the right:
Filepath+oldfilenamesubstring(0,2)+oldfilenamesubstring(4)+_page_i++_+suffix+.pdf in the extract section
So, my example must result in 7 pdf's:
4P12345-1_page_1_BG.pdf (with content of page 1)
4P12345-1_page_2_BG.pdf (with content of page 2)
4P12345-1_page_3_BG.pdf (with content of page 3)
4P12345-1_page_4_BG.pdf (with content of page 4)
4P12345-1_page_5_BG.pdf (with content of page 5)
4P12345-1_page_6_BG.pdf (with content of page 6)
4P12345-1_page_7_BG.pdf (with content of page 7)

Similar Messages

  • Applescript create folder from filename and move file stopped working

    Hi,
    For a while I've used this script but after upgrade and a new machine it stopped working.
    I have  Mac OS 10.8.5.
    This is what I have.
    Images (folder)
    111111_00.jpg
    111111_01.png
    222222_01.jpg
    222222_02.png
    222222_03.gif
    I'd like to be able to create a new folder for each "group of files" (new folder 111111, new folder 222222) and move the appropriate files into each of them.
    The filenames are always built by 6 digits underscore and 2 digits. Can be whatever filetype. (123456_01.jpg)
    I have a script that used to work just fine but now it just creates one folder and then freezes.
    This is the script that doesn't work.
    set chosen_folder to (choose folder)
    tell (a reference to my text item delimiters) to set {old_delim, contents} to {contents, "_"}
    tell application "Finder"
        try
            set file_list to files of chosen_folder
        on error
            set file_list to {}
        end try
        repeat with this_file in file_list
            set folder_name to name of this_file
            if folder_name contains "." then set folder_name to ((text items 1 thru -2 of folder_name) as string)
            set new_folder to ((chosen_folder as string) & folder_name & ":")
            try
                get new_folder as alias
            on error
                make new folder at chosen_folder with properties {name:folder_name}
            end try
            move this_file to folder new_folder without replacing
        end repeat
    end tell
    set my text item delimiters to old_delim
    I know that there are many who can do this easy as pie, but if you can find it in your hearts to help me it would be much appreciated.
    K

    function createFolder(file) {
      var parentFolder = file.parent;
      var saveFolder = new Folder( parentFolder + '/' + file.name.substring( 0, 8 ) );
      if( !saveFolder.exists ) saveFolder.create();
      var saveFile = new File( saveFolder + '/' + file.name);
      if( file.copy( saveFile ) ) file.remove();
    function main() {
       var folder = new Folder("~/Desktop/images");
       var files = folder.getFiles();
       for (var i = 0; i < files.length; i++) {
         var f = files[i];
         if (f instanceof File) {
          createFolder(f);
    main();
    Something like that should work.

  • Having arranged some scanned pictures in an album in I-Photo how can I keep them in the order I have chosen when I move the album. They all have the scan date and not the taken date and move to new positions if I move them from one album to another.

    Having arranged some scanned pictures in an album in I-Photo how can I keep them in the order I have chosen when I move the album. They all have the scan date and not the taken date and move to new positions if I move them from one album to another.
    Is there any way to re-number them in the order I have chosen so that they can then be sorted by number? The scans are all from pre-digital images that I wish to move to a photobook and I don't want to have to organise them twice!
    Thanks for any suggestions.

    I was a bit short, Chris, sorry. It is limited, what can be posted, when typing on an iPad.
    Now I am back on my Mac. I meant the following:  Batch Change the date for a large range of photos, that should have a date stepped in increments.
    Select all Photos at once and use the command "Photos > Batch Change".
    Then set the date for the first photo and select an increment, e.g. one minute.
    Now all photos will get a new date assigned, incremented by one minute, in the sequence you have selected. So you will be able to sort them by date.  This way it will be unnecessary to change the titles or filenames.

  • TS4002 How to sign out from iCloud and move to another one without deleting the fist one?

    I need to get out from iCloud account to get in to another but without deleting the first one. It's a long story and it's pretty messed up. I really need your help guys. IF it's possible to sign out from iCloud and move to another PLEASE tell me ! Thanks in advice!

    Welcome to the Apple Community.
    You can sign into more than one account at once, providing you only need one primary account, what exactly are you trying to do.

  • Read the job Z_JOB from SM37 and re-schedule dynamically

    Hi All,
    I have one requirement where I need to schedule a job in background. The job Z_JOB has 10 steps in it and each step itu2019s calling different program with a variant. Now I need write a Z program to re-schedule the Z_JOB dynamically.
    I know how to schedule the job with multiple steps through program. (JOB_OPEN, Submit Statement, JOB_CLOSE). But my question is there any other way to read the job Z_JOB from SM37 and re-schedule dynamically. So that I can avoid this 10 SUBMIT programu2026??
    Thanks in Advance,
    Raghu.

    Hello Raghu  ,
    JOB_OPEN ( Opens  a BG job )
    JOB_SUBMIT ( Insert a background Task)
    JOB_CLOSE (Closes a BG job)
    Are the 3 function module by with you can create a have  a bg job sheduled programatically...!
    Hope it helps
    Edited by: Anup Deshmukh on May 3, 2010 12:36 PM

  • I am having trouble reading some books bought from ITunes and loaded onto my Cocoon ereader which supports  Adobe DRM content.  Any suggestions?

    I am having trouble reading some books bought from ITunes and loaded onto my Cocoon ereader which supports  Adobe DRM content.  Any suggestions?

    matty_234 wrote:
    Will this enable me to plug my iPhone in without any changes or reformatting? ...
    If you follow all the Steps in the Link it should...
    matty_234 wrote:
    .... Also, I guess this will overwrite the purchases already on my mac? ...
    You can redownload them for free...   http://support.apple.com/kb/HT2519
    matty_234 wrote:
    ... One last thing, does this include the iphone backups?...
    Everything that is in iTunes should be there...

  • Hi, I would like to copy my photos (from iphoto) and movies (from i movie) from my Mac book air to my imac in which I also have iphoto and imovie with photos and movies. My goal is to have a unique source in my imac for my photos and movies. Thanks .

    Hi,
    I would like to copy my photos (from iphoto) and movies (from i movie) from my Mac book air to my imac in which I also have iphoto and imovie with photos and movies.
    My goal is to have a unique source of photos and movies in my imac.
    Thanks !
    Nicolas

    As  to iPhoto
    Connect the two Macs together (network, firewire target mode, etc)  or use an external hard drive formatted Mac OS extended (journaled) and drag the iPhoto library intact as a single entity from the old Mac to the pictures folder of the new Mac - launch iPhoto on the new mac and it will open the library and convert it as needed and you will be ready move forward.
    For iMovie support please post in the iMovie forum
    LN

  • Can you move a row in a DataGridView to the first row and move the other rows down to make room?

    I'm using a DataGridView (I call it "dg") to display a list of items. I want the user to be able to position the cursor on a row in the middle of the list then click a button to move that row to the top of the list (and move the other rows between
    the first row and the row being moved down one row to accomodate the new first row).
    Robert Homes

    Hello,
    If the DataGridview does not have it's DataSource set we can use the following logic
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim data = (From T In DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells.Cast(Of DataGridViewCell)() Select T.Value).ToArray
    DataGridView1.Rows.RemoveAt(DataGridView1.CurrentRow.Index)
    DataGridView1.Rows.Insert(0, data)
    End Sub
    If the DataSource is set then we need to do what was done above but against the underlying data rather than the DataGridView itself. The base logic can be found in
    the following article in LanguageExtensions.vb but please note the code there is for a different type of move yet the logic is still the same in the end.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • Jasper report on HTML when one image loaded from database and for the other

    How to generate jasper report on HTML when one image loaded from database and for the other we give a image path
    My code
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
              exporter = new JRHtmlExporter();
              exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
              exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
              exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, strImageInputDirectory);
         exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME, strImageOutputPath == null ? "." : strImageOutputPath);
         exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE);
         exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
         exporter.setParameter(JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
              exporter.exportReport();
              byte[] bdata = ((ByteArrayOutputStream) baos).toByteArray();
    Can any one help pls
    Message was edited by:
    ameet.au

    hey sorry for posting it in this forum.
    but do u have sample code for making it work.. since i am able to do it on PDF format(image from Database and another stored in the webserver) using
    byte image[] =(byte[]) outData.get("image");
                        ByteArrayInputStream img = new ByteArrayInputStream(image);
                        hmimg.put("P_PARAMV3", img);
    print = JasperFillManager.fillReport(reportFileName, hmimg, jrxmlds);
    bdata= JasperExportManager.exportReportToPdf(print);

  • Can you download a rental movie from itune and move to an external drive

    How can I export an itune movie to an external drive?
    If I can download a rental movie and move to an external drive?

    Hi Niel.  Can you be move specific for those of us not tech savy?   1 - Can you provide steps to back up the library?  2 - How do you organize the library?  3 - When you move the entire iTunes folder, does it include iTunes paid for music along with downloaded music from CDs?  Thanks

  • How to read mutiple excel columns from clipboard and populate table control

    Hi All,
    I have a requirement to populate two columns in table control from excel using clipboard. (Copy two columns from excel and then, click on a button on the screen and table control's two columns should be filled).
    I am using FM CLPB_IMPORT to get clipboard values.
    eg: I am getting clipboard values as        val1#val2
                                                                     val3#val4   
    where each row is a row in excel and # indicates the columns.
    The problem here is that I am not able to split val1 and val2 using the SPLIT statement using # character.
    Any ideas will be appreciated.
    Regards,
    Arun Mohan

    Hi,
    Try suing the below code instead of "#" in the SPLIT statement.
    CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    Regards,
    Naveen
    Edited by: Naveen Kumar on May 13, 2010 1:48 AM

  • Adjust end of clip and move all other clips accordingly

    having found this help topic about trimming clips: Adobe Premiere Pro Help | Trimming clips, i figured i might be able to figure out how to adjust the end of a clip and move all subsequent media content accordingly.
    the situation would be: adding a word to dialogue, cutting out a word, something like that -- where you have to shorten or lengthen a clip, and you need to move all subsequent content accordingly.
    i used to know the name of the folks that did the study in the late 90's regarding help file "readability," which then resulted in the trend that help files don't offer the ability to dig deeper into the definitions of a software's vocabulary, but i forgot.
    at any rate:
    i don't know what the blue thing is called with which one moves around on adobe's timeline.
    now, i'm assuming i'll be able to dig that up.
    but i have a series of graphics -- and i want to move adjust the length of time graphic1 appears (let's say extend it's length). i'd like to "bump" or "move" or "ripple," or "roll," or "regular edit," the graphic so that -- when i move the right side of the graphic -- all subsequent graphics get "bumped" to the right (later in time).
    while i appreciate the alliteration of regular ripple and rolling edits, i did need to try them out to see what they do.
    and none of them appear to "bump" all subsequent content.
    i gather that i could "lasso" all of the subsequent content and nudge it and/or move it around -- but really -- i'd like to be in clip 19 -- adjust when that clip ends -- and move all subsequent content either later or earlier in time -- accordingly.
    ideally that "desire" would extent into: i am just going to move visual content, and "i am going to move visual and audio content."
    please have compassion for my "negative" tone, because i am having a bit of a "losing faith in humanity" moment right now - because i took about a 5 year break from tech and am now returning to tech -- and i expected user procedures to have improved.
    i'll be OK and will likely blog about it, but for now: can you either tell me some keyboard shortcuts or direct me to help files or just explain -- how to edit the various types of content in premiere the way i've outlined?
    i want to move all of the subsequent content over to the right. i do not want to just move the end of the last clip and the start of the next clip -- keeping the end of the next clip in the same place (which is apparently what the red double double arrow does).
    i seem to have tried out "regular, ripple, and roll," and maybe i'm almost there -- or one of those methods actually works -- but the word that is coming to mind is "bump."
    bump or nudge or adjust...
    anyway -- got any tips?

    hey Michael, your reply helps restore my faith in your humanity -- but seriously -- i need to use the "ripple delete tool" to NOT delete -- but extend and push?
    really?
    that is as obnoxious as going to the start button to shut down.
    how about going to the shut down button to start? how about that Bill Gates.
    and we still can't tell the difference between a lowercase l and an uppercase I online. Good job humanity. Sometimes even the 1 is the same as l and I  -- so you have 1lI  all looking the same.
    My 8 year old daughter thought I live in LLLinois? She was trying to read Illinois.
    Of course I have to go to "delete" to extend. What else? I have to go to start to shut down.
    ps --- that is why humanity has gone through the effort to call those thingies on doors: handles. See a handle can be used to open AND close a door.
    it is not the "close knob" it is the "door knob." why? because you can use it to open and close.
    it is not the on/off button -- though some call it that -- it is the "power" button.
    You go through the effort to create vocabulary that makes sense if you are going to create and sell software. I understand that sometimes it can be hard, but there are plenty of people, myself included, who have the intellectual capacity -- to find or create these kinds of cohesive procedural flows -- to a large extent due to our linguistic abilities.
    it's not rocket science, but it is, in a particular way -- quite difficult. it requires mental effort or some kind of "capacity," to realize that a "handle" often moves us between two or even more states -- like: open and closed.
    that is why we do not call it the "on" button.
    what does my HP printer have? oh it has an "on" button.
    dumb dumb dumb dumb
    more dumb
    and then -- i am even accosted with dumb -- from adobe?
    like awesome software industry standard adobe?
    like "we made PDF files" adobe?
    are you serious?
    ugh -- ok i will go to "delete" to NOT delete and extend
    i don't even care what that yellow thing is called anymore. i am just going to press command and click and get this project done for now...

  • Time Stamp, read from filename and change automatically

    Hi,
    while converting to an format (video monkey) which can be read by iMovie the files lost the propper time stamp. However, date and time is still part of the filename. Is there an option to change date and time within iMovie or any other app based on the file name so that I do not need to make this manualls for each individual file?
    Rgds
    barino

    I would suggest using the ISO-8601 UTC format.
    The only limitation is that the string value is in reference to GMT.
    The conversion of the string back to a timestamp will present the date/time on your front panel indicator as local time.
    https://lavag.org/topic/15034-timestamp-support-for-format-into-string-scan-variant-from-string-stri...
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • Reading a TXT file from a Flash Movie

    Using "LoadVariables" to establish a connection between the
    running Flash program and a text file in the same folder works just
    as expected with no problems. I am on a Windows machine and using
    the recipe from the fabulous help system.
    The problem - yes there IS a problem - arises when the text
    file contains special Danish characters.
    The odd part here is, that everything works fine from inside
    Falsh using "Test Movie", but not when publishing the movie and
    launching from inside a browser (both IE and Firefox).
    The help system says, that data should be URL-encoded. Trying
    that (characters %e6, %f8 and %e5) does not fix anything. The input
    is read, but the offending character is gobbled up along with the
    two next characters, or the program simply hangs.
    Any suggestions?[

    No i didn't do that in my first series of tries. Following
    your suggestion I did that (embedding Latin I, that should contain
    all the necessary characters), but it didn't do the trick. Actually
    it prevented my writing to a dynamic text field intended to
    interact with the user.
    Using English cahracters only it worked fine (with invisible
    text ;-) ).
    Using Danish characters I got the same result: Not working
    properly.
    Using the Danish characters from inside Flash to fill in text
    fields (static, dynamic and input) normally works fine, so I am
    puzzled - still

  • Get filename and move on

    Hi there
    I am trying to find a way to through a folder containg a not of files.
    What I want is to read the filename of every file in the folder, and based on every filename write a line(the filename) out into a new file.
    So I need something that can do like this:
    1. read filename for the file
    2. write this filename to a new file
    3. move on to next file
    This should loop until there are no more files.
    Can someone help?
    Reagards
    Tolstrup

    It is a lot easier than that.
    Make a new File object that points to the directory you want to read from.
    File directory = new File("C:\Documents and Settings\All Users\Desktop");Then use listFiles() to get a list of all the files in that directory:
    File[] files = directory.listFiles();Then loop and print:
    for (int i = 0; i < files.length; i++) System.out.println(files);

Maybe you are looking for

  • Re: Nokia Lumia 520 music problem

    I bought a 520 2says ago. Created a nokia account, everytime i try using the music app to download a new song says we had problems registering your device for nokia unlimited music services.

  • Config XDB for https ssl access

    Hello, I'm trying to configure an Oracle DB 11g for https access. I tried to set the port to 8089 and the protocol to tcps. When I execute the following lines of code, I always get an Error, that the xml-file is not ok. But when validate the output o

  • Web Gallery: image adjustments during creation of web gallery?

    I've noticed that when my images get uploaded to a web gallery, they look very different: it looks like they've been gamma'ed up, desaturated and had sharpening applied. It's quite a significant difference and it don't look good. I checked to see if

  • Priventing WLS user from login into OBIEE 11g

    I have 100+ users in Weblogic. Only some users say 60 are allowed to access OBIEE 11g. How do I prevent other users from login into OBIEE (When they have OBIEE url :) ). Thanks, Mod

  • Flv video format converter code in c#?

    I have different types of video formats like(mp4,wmv,etc). I want to convert this video formats into .flv. Please help me by using c#,jquery .. Nothing is impossible...