How do I use the containing folder's name to rename files on export

I'm trying to write a script that takes the folder name that the active document resides in and uses it as part of a new name.
So, let's say I have a file called "strawberries.jpg" that is 1000x1000px and resides in a folder called "good-fruit". I want the script to export the final file as a TIFF like this:
good-fruit/good-fruit-strawberries-1000x1000.tiff
Thus far, I've managed to use alerts to figure out how to grab document name, beginning size, current folder path:
var doc = app.activeDocument; var dirName = doc.path; var cropWidth = doc.width.as('px'); var cropHeight = doc.height.as('px'); alert("This document is " + doc.name + " and is " + cropWidth + "x" + cropHeight + " and resides in: " + dirName ); 
Which results in an alert that says: This document is strawberries.jpg and is 1000x1000 and resides in: ~/Desktop/Folder/good-fruit/
But I cannot figure out how to cut off the beginning of doc.path (i.e. ~/Desktop/Folder/) so I can just add "good-fruit" to the final name. I also can't figure out how to insert "good-fruit" before the extension of the image.
Thanks for any help!
Joe

It is regular expression and yes it is use for pattern matching. The forward slashes are used to start and end the expression when it is create this way( literal ). Another way to create one would be to make an explicit declaration var re = new RegExp('\.[^\.]+$').
Some chars in regular expressions have special meaning. The dot char normally means match any char. The blackslash is used to escape that special meaning so \. means match the dot char. The [ and ] are used for char sets. Those are normally used when you only want to match specific chars [aeiou] would match any English vowel. The ^ used inside the brackets means 'not' so [^\.] means match any char that is not a dot( or any char except an dot ). If used outside of brackets the ^ char means at the start. The + means match the preceeding one or more times. In this case match any non dot char one or more times. The $ means at the end of the string.
So putting that althougher you have 'match a . followed by one or more chars at the end'.

Similar Messages

  • How can I use the versionning tool to make a coherent solution to export

    how can I use the versionning tool to make a coherent solution to export all objects used in my project to other db schema for testing as well as for implementation .
    I want to know proper steps to Import/export objects.
    while I am exporting my Master repository and work repository then again importing the all , no problem comes all the physical logical schema mapping and mapping between interfaces retains but
    while I am trying to export and import one or two packages on the ease of testing then I am getting so many mismatches manually I am setting all why so?
    required ur suggestion
    Palash Chatterjee

    kelly-bot wrote:
    Thanks for the tip, but like I said, I dont want to always have to use the arrow keys. Is it not possible to actually DRAG one pixel at a time? I recently upgraded to CC from CS3 and I keep running into things that feel like a downgrade. Super disappointed.
    Our posts overlapped there.  Are you saying you could reliably drag one pixel with CS3? 
    What other issues are you having?  Things like the Crop tool can feel strange at first, but I promise you you'll never want to use Classic mode once you get used to it.

  • HT4597 I use the public folder on idisk to share files with a colleague. Will I be able to do the same on iCloud?

    I use the public folder on idisk to share files with a colleague. Will I be able to do the same on iCloud?

    No. There is no iDisk with iCloud. You can use one of several third-party alternatives like SugarSync, ADrive, or MediaFire.
    Basic Information About Moving From MobileMe to iCloud
    Apple IDs and iCloud
    Creating an iCloud account- Frequently Asked Questions
    Frequently asked questions about the MobileMe transition and iCloud
    MobileMe services that no longer sync after moving to iCloud
    MobileMe- About moving to iCloud

  • How can I use the same Game Center name on my iPad and my iPhone?

    Is there any way to use the same Game Center name on two devices?

    If you signed into Game Center in Settings > Game Center on both devices with the same Apple ID, you should have the same name in both centers.

  • My user data ( music, movies, et. al.) take up too much space to fit on my SSD. How do I use the user folder I've copied to my new iMac's hard drive?

    As above. I can use Migration Assistant to move my account from my old machine, but the data are far too extensive to fit on the solid state drive. I copied my user folder over to the new hard drive, but how do I access its contents? More accurately, how do I set the folder on the hard drive as my default storage space?

    Hello, very good info here...
    http://macs.about.com/od/diyguidesprojects/qt/Move-Your-Home-Folder-To-A-New-Loc ation.htm

  • UTL_FILE: How do you use the ^ as a delimiter from an ASCII file?

    We currently have UTL_FILE pulling in a comma delimited file,
    with this code: With the V_COMMA's declared and other variables
    declared listed below. It works. When we change the ASCII file
    to ^ delimited, the program fails. How do we get the ^ to work
    with UTL_FILE?
    BEGIN
    UTL_FILE.GET_LINE(V_FILEHANDLE, V_NEWLINE);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    EXIT;
    END;
    /* adding numbers 1-6 to position one on newline*/
    V_COMMA_1 := INSTR(V_NEWLINE, ',', 1, 1);
    V_COMMA_2 := INSTR(V_NEWLINE, ',', 1, 2);
    V_COMMA_3 := INSTR(V_NEWLINE, ',', 1, 3);
    V_COMMA_4 := INSTR(V_NEWLINE, ',', 1, 4);
    V_COMMA_5 := INSTR(V_NEWLINE, ',', 1, 5);
    V_COMMA_6 := INSTR(V_NEWLINE, ',', 1, 6);
    V_ITEM_NUMBER := SUBSTR(V_NEWLINE, 1, V_COMMA_1 - 1);
    V_AVAILABLE := SUBSTR(V_NEWLINE, V_COMMA_1 + 1, V_COMMA_2 -
    V_COMMA_1-1);
    V_ETA_CHAR := SUBSTR(V_NEWLINE, V_COMMA_2 + 1,
    V_COMMA_3 - V_COMMA_2-1);
    V_RETAIL_PRICE := SUBSTR(V_NEWLINE, V_COMMA_3 + 1,
    V_COMMA_4 - V_COMMA_3-1);
    V_DROP_SHIP_FILE := SUBSTR(V_NEWLINE, V_COMMA_4 + 1,
    V_COMMA_5 - V_COMMA_4-1);
    V_COMPANY_FILE := SUBSTR(V_NEWLINE, V_COMMA_5 + 1);

    Thanks for your response!
    I have simplified the sheet so it contains no split or merged cells, yet still I get the exclamation mark where I want the average. (The exclamation mark says 'Numbers can't be divided by zero'.)
    Exam
    Skit
    Exam
    Class Participation
    1
    2
    TOTAL
    MAX. MARK
    55
    30
    100
    15
    200
    ADJ. %
    MARK
    Student A
    37
    20
    84
    15
    156
    78%
    72%
    7
    Student B
    39
    28
    91
    15
    173
    87%
    80%
    8
    Student C
    39
    28
    86
    10
    163
    82%
    76%
    8
    Student D
    34
    26
    92
    15
    167
    84%
    78%
    8
    Student E
    38
    26
    74
    10
    148
    74%
    69%
    7
    CLASS AVERAGE
    37.4
    25.6
    85.4
    13.0
    161.4
    80.7%
    75.0%
    I guess the basic question is: can you actually use AVERAGE on data that is output by an IF formula?

  • How do I use the links folder for bookmarks the same as in IE?

    Until today I was using IE8. In the bookmarks there is a folder named "Links." These would display across the top of the screen like a toolbar (with subfolders acting as dropdown menus.) I want to set this up the same way in FF. Is there a setting/toolbar/addon/... to accomplish this?

    It is called the Bookmarks Toolbar in Firefox. <br />
    https://support.mozilla.com/en-US/kb/Bookmarks+Toolbar

  • How can i use the project code instead of project xml?

    hello
    i use the sessionbean+toplink structure,after i finish the o-r mapping by using the mapping work bench,i generate the project xml file,then in the "session.xml" file,i refer to the project xml,then i can use it from sessionbean.
    i hear that if i use the project code instead of project xml file,it will be more performant,is that true?
    otherwise,how can i use the project code instead of project xml file?i mean, in "session.xml", i can use the "<project-xml>" tag to refer to the project xml file,then in my session bean,i get the server session by read the "session.xml" file.but if i use the project code,how can i refer it from the "session.xml"?the examples that come with the toplink installation only tell me how can i use the project xml file within the session bean,it don't give me any clue about using the project code in the sesion bean,who can give me a step-by-step instruction and code snippet?
    thank you very much?

    There is a slight performance gain during session load at startup but there is no difference at runtime. The choice of which to use is dependent upon you build process. Whether it is easier to submit a new version of the class into the comile build process vs an XML file. In most cases it is just a preference of the development team.
    When you use the project-class you'll need to generate the source code and compile it into your system. Typically it is packaged with the persistent classes. You may need to configure your environment so that the class-loaders have access to these classes (same for the XML case).
    When using the project-class you simply replace the project-xml entry like this:
    <project-class>oracle.toplink.demos.employee.relational.EmployeeProject</project-class>
    The DTD for the session.xml file is found at <TOPLINK_HOME>\core\sessions_4_5.dtd. It is also in the documentation at:
    http://otn.oracle.com/docs/products/ias/doc_library/90200doc_otn/toplink.903/b10064/a-sessio.htm#634246
    Doug Clarke
    Product Manager
    Oracle9iAS TopLink

  • How do I make the Volumes folder visible so it will back up using Time Machine?

    Hi
    How do I unhide the Volumes folder for backing up using Time Machine?

    OK I have to say this even though you probably realize it, having anything but mount points in the Volumes folder, especially regular files that are critical to you is really a bad bad idea. 
    You should do everything in your power to correct this asap.
    In the meantime as to Time Machine, your profile says you are running 10.6.8 is that correct? TM has changed some since then.
    Basically if you are not excluding system files from the backup the Volumes folder should be in the backup. If the regular files are in there is an other issue.
    You can check by opening a Terminal window cd to your TM backup drive then into the .backup folder. Pick a backup and see if the Volumes folder is there and if the files are in it.
    But again having anythgin in there is going to be a problem.
    good luck

  • How to check for the sub folder in the document library Is already Exist using CSOM?

    Hi,
    My requirement is to create the  folder and sub folder in SharePoint document library. If already exist leave it or create the new folder and the subfolder in the Document library using client side object model
    I able to check for the parent folder.
    But cant able to check the subfolder in the document library.
    How to check for  the sub folder in the document library?
    Here is the code for the folder
    IsFolder alredy Exist.
    private
    string IsFolderExist(string InputFolderName)
    string retStatus = false.ToString();
    try
    ClientContext context =
    new ClientContext(Convert.ToString(ConfigurationManager.AppSettings["DocumentLibraryLink"]));
                context.Credentials =
    CredentialCache.DefaultCredentials;
    List list = context.Web.Lists.GetByTitle(Convert.ToString(ConfigurationManager.AppSettings["DocumentLibraryName"]));
    FieldCollection fields = list.Fields;
    CamlQuery camlQueryForItem =
    new CamlQuery();
                camlQueryForItem.ViewXml =
    string.Format(@"<View  Scope='RecursiveAll'>
    <Query>
                                            <Where>
    <Eq>
    <FieldRef Name='FileDirRef'/>
    <Value Type='Text'>{0}</Value>
                                                </Eq>
    </Where>
    </Query>
                                </View>",
    @"/sites/test/hcl/"
    + InputFolderName);
                Microsoft.SharePoint.Client.ListItemCollection listItems = list.GetItems(camlQueryForItem);
                context.Load(listItems);
                context.ExecuteQuery();
    if (listItems.Count > 0)
                    retStatus =
    true.ToString();
    else
                    retStatus =
    false.ToString();
    catch (Exception ex)
                retStatus =
    "X02";
    return retStatus;
    thanks
    Sundhar 

    Hi Sundhar,
    According to your description, you might want to check the existence of sub folder in a folder of a library using Client Object Model.
    Please take the code demo below for a try, it will check whether there is sub folder in a given folder:
    public static void createSubFolder(string siteUrl, string libName, string folderServerRelativeUrl)
    ClientContext clientContext = new ClientContext(siteUrl);
    List list = clientContext.Web.Lists.GetByTitle(libName);
    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml =
    @"<View Scope='RecursiveAll'>
    <Query>
    <Where>
    <Eq>
    <FieldRef Name='FSObjType' />
    <Value Type='Integer'>1</Value>
    </Eq>
    </Where>
    </Query>
    </View>";
    //camlQuery.FolderServerRelativeUrl = "/Lib1/folder1";
    camlQuery.FolderServerRelativeUrl = folderServerRelativeUrl;
    ListItemCollection items = list.GetItems(camlQuery);
    clientContext.Load(items);
    clientContext.ExecuteQuery();
    Console.WriteLine(items.Count);
    if (0 == items.Count)
    //create sub folder here
    Best regards
    Patrick Liang
    TechNet Community Support

  • Help with Adobe.premiere.elements12. Please It would appear under the organizer tab that the photos are organised in the lowest folder in the folder structure within Windows Explorer.  How can I use the Windows Explorer structure to organise the photos wi

    Help with Adobe.premiere.elements12. Please
    It would appear under the organizer tab that the photos are organised in the lowest folder in the folder structure within Windows Explorer.  How can I use the Windows Explorer structure to organise the photos within Elements.

    In a situation such as yours, I tend to consolidate items into folders so I have folders of nice workable numbers of images, somewhere between 20 and 200 images. Now, whatever, once you've imported, do your moving within LR, not the OS! I will select all in a folder and drag into a folder a level or two or three above, and then delete the newly empty subfolders. I hope this helps a bit!
    Once you've reached just new Imports of camera output, you'll be flying along.

  • I've update my music using an external disk; now I uploaded agin the music  but it doesn't appear in Itunes. How can I synchronize the music folder with Itunes?

    I've managed my music downloading and uploading it from an external disk; I put the music into the Finder MUSIC folder and copyed it into Itubìnes but it does't appear. What Do I have to do? How can I synchronize the Musice Folder with Itunes?

    Chris, thanks for the reply.
    That's what I'm confused about. I did exactly what you said. I copied the entire music folder from the old computer and put it in the music folder on the new computer. I've tried that two or three times now. And, I've checked, and all of the files are there (that's what I meant by 'clicking on Itunes Media'--when I click on the iTunes media folder in music/itunes in Finder, all of the files are there). But, when I open iTunes, nothing shows up--no movies, no music, no tv shows. It seems like it should be so simple, but it won't work for me.
    Any ideas?
    Thanks so much.

  • How can i open the directory/​folder and read all the files inside it in order and then close it?

    How can i open the directory/folder and read all the files inside it in order and then close it? any example would be nice.
    thanks

    In the File I/O>>Advanced File Functions Palette is a function named "List directory". This function will give you two arrays. One contains the names of all subdirectories the other the names of all files. If you want to sort them by name use the array sort function. If you want to sort them by another attribute use the File/Directory Info function to get more data. Use a cluster which contains the attribut to sort and the original index of the name. Then sort this array.
    Waldemar
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • I'm running Pages version 5.2 on a Desktop Mac version 10.9.2. with the Pages app open how do I use the Time Machine to go back five hours to see the work?

    I'm running Pages version 5.2 on a Desktop Mac version 10.9.2. With the Pages app open how do I use the Time Machine to go back five hours to see my page? Can I access Time Machine within an app like Pages? How do I enter Time Machine within the application? It always takes me to the Finder. I apolgise for the mumbo jumbo. I simply do not know how to use Time Machine. It makes sense when I follow the Tutorial but then I lose it.

    OK. You've kind of skipped over the reason why you want to go back five hours, but my assumption would be that you've made changes to a Pages file that you want to revert.
    There are two ways to tackle this. From Pages itself, open the current version of your document, and from the File menu, click Revert To, and Browse All Versions. You'll then be in the Time Machine interface for that file, and can browse back to the version you want.
    Or, outside of Pages, you can select the file (or the folder it was originally in, if you've since deleted it) and enter Time Machine from the TM menu (it sounds like you've already tried this?)
    best
    Matt

  • I was trying to get the iOS 8.2 on my iPhone 5 but then it stopped and my phone is now on recovery mode I have pictures I need and they did not all fit on iCloud  how can I use the phone again with ALL my pictures and videos without restoring it?

    I was trying to get the iOS 8.2 on my iPhone 5 but then it stopped and my phone is now on recovery mode I have pictures I need and they did not all fit on iCloud  how can I use the phone again with ALL my pictures and videos without restoring it?

    Contacts are designed to be synced to a supported application on the computer or a cloud service.
    Pictures taken with the device are designed to regularly be copied off the device to a computer as would be done with any digital camera.
    If you have failed to use the device as designed it may be too late to recovery anything.
    Is the device regularly backed up to a computer via iTunes?  If so, the most recent backup (when restored to a replacement iOS device) should contain all contacts and pictures as of when the backup was created.

Maybe you are looking for

  • Itunes could not back up iphone because backup could not be saved on the PC

    I am not able to backup my iphone. After the last step it always comes up with this message "itunes could not back up iphone because backup could not be saved on the computer" . I tried all solutions mentioned earlier like changing time zone, deletin

  • Custom SRM workflow: task forwarded to last change author when approving.

    Hi experts. We encountered this strange behaviour when approving a Purchase Order, previously rejected. More precisely: the PO is created by user A, user B rejects it, user C approves it, then the same workitem sent to C is forwarded to B instead of

  • Can't import into imovie using HV20 as AV/DV bridge

    I've trying to import some old VHS footage from a VHS player to imovie v6.0.3 using a Canon HV20 as a analogue to digital convertor. I've got about 30GB free space on my Intel imac. It captures a fraction of a second of VCR image and then switched to

  • Workflows and OWB 10.1

    We have run into a brick wall here and need some advise on how to proceed: Our DW has >50 facts and dimension tables, for each table we have a mapping that loads the table from an external table and a process flow (workflow) that: - looks out for the

  • Simple Mp3 Player EQ Style Playlist

    I'm trying to find a simple eq like mp3 player like this http://www.flashkit.com/movies/Sound/Players/Small_EQ-Cosmin_V-11746/index.php that will play a few tracks automatically and when done it will start again with the first track? Can anyone point