AppleScript / saving file to a relative path

Hello everybody,
I would like to make a script that saves current file to a relative path. For example: I have a psd opened file (that is in pictures/01/image01.psd) and I need to save it one level up as a JPEG ( pictures/image01.psd).
This is what I've tried, however, the result is that the file is saved in the root of Photoshop - in applications folder:
tell application "Adobe Photoshop CS6"
          set myFile to "./"
          set myOptions to ¬
                    {class:JPEG save options, embed color profile:false, format options:standard, matte:background color matte} ¬
  save current document in file myFile as JPEG with options ¬
  myOptions appending no extension without copying
end tell
Thanks in advance

I need it 1 level up no matter where - since there will be different folders.
Thanks!

Similar Messages

  • How to open a configurat​ion file with a relative path?

    I want to open a configuration file during the initialization of my application (first "state," u can say) and I am using "Open Config file.vi" and tried to pass the config file's path as "data\myconfig.ini" and the "File exists?" vi didn't give any error (simply, the output was "false") but the Open config File gave an error.
    If I pass an absolute path "D:\xyz\xyz\myconfig.ini" it works fine. Isn't it allowed to use "relative path" as I remember using it before for other tasks?
    I actually prefer to have this file in the "data" folder that my application's setup will create in the destination directory while installing the application, because it will be easy when I want to ask the user to open and edit it. Or, I would just put it in "C:\" which exists on all the windows computers, but then it would be too much open.
    Thanks ahead!
    Vaibhav
    Solved!
    Go to Solution.

    Relative paths have sometimes a meaning for command line tools (where a relative path gets appended to the current path, which usually is the executables directory).
    But for Windows GUI applications that makes not much sense. Windows also maintains a per process current path, but that path gets updated by several Windows APIs, one of them being the File Dialog. So whatever your user has last selected in any file dialog inside your application will from then on be the applciations current path. It should be clear that with such a braindamaged current path implementation it has basically no useful meaning, and LabVIEW consequently does not do path expansion, where relative paths are expanded by prepending them with the applications current path.
    Also LabVIEW uses mostly the Windows 32 Bit API, which does provide the current path implementation but does almost not use it in any of its file operations. The use of that feature is mostly reserved for the Windows shell API, which is a higher level API that can as best be described as a collection of various APIs that have been thrown together by whatever some MS developer felt at the moment. You can not by any means call it a designed API at all, and LabVIEW makes almost no use of it, as it needs lower level access, to make its operation similar in its working across all the platforms, LabVIEW can run on.
    So while you can work with relative paths inside your application (and actually should as much as possible to make your application not depend on a particular location) you should make that path absolute whenever you pass it to a function that actually accesses a file somewhere.
    Rolf Kalbermatter
    Message Edited by rolfk on 09-08-2009 11:31 PM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to load a .properties file by giving relative path in a JSP file.

    Hey guys,
    I'm trying to load a .properties file in a JSP using relative path...
    It is not taking the properties file..
    What is the problem...?
    Any solution..?
    Thanks a lot.

    Yes I tried that also.
    Your path was something like this ?
    http://localhost:8080/Database/a.properties ?
    Whether this path will change after client installation ? if no then what's the problem ?
    For client side installation how you are going to set your conf directory for your application ?
    You are not going to give client installation page ?which will have all the values to be set like conf path. database,user name(s),log folder,temp folder etc ? Why you are keeping everything on server ?
    Check if this is useful,
    String context = request.getContextPath();
    String rmtAdd = request.getRemoteAddr();
    String host = request.getRemoteHost();
    out.println("http://"+rmtAdd+context+"<BR>");
    out.println("http://"+host+context);
    "http://"+rmtAdd+context
    Edited by: kanad on Jan 12, 2008 1:29 PM

  • Properties-file with a relative path...

    Hello everybody,
    my question is as follows:
    I have a directory-structure like below:
    root_dir
    |
    -- source
    |
    -- classes
    |
    -- libs
    |
    -- xmlfiles
    |
    myproperties.propsIn words: my root_dir (is actually a subdirectory in my fs) contains folders like source (java-files), classes (class-files)... and a properties-file myproperties.props. The source-dir has subdirs like com/xyz/bla/Mainclass.java...
    I want to load the properties-file from the main-class, but without using the absolute path. That's the way I do it at the moment:
    Properties props = new Properties();
    props.load(new FileInputStream("d:\\foo\\something\\root_dir\\myproperties.props"));But I don't want to write the whole path, because of portability (forget the \\ :) )!
    How can I obtain the root_dir?
    Thanx for helping!
    Regards, Robert4

    Well I was already working on a replacer for /../ stuff before I was pointed to the File class. Not the best code I've written, but works fine. Perhaps it could be of use to you.
        public void setCoordinatesFileURL(String coordFileURL)
            coordinatesFileURL=coordFileURL;
            //replace .. to get canonical path
            StringTokenizer st = new StringTokenizer(coordinatesFileURL,"/");
            String[] stringURL= new String[st.countTokens()];
            int teller=0;
            while(st.hasMoreTokens())
                String token=st.nextToken();
                if(!token.equals(".."))
                    stringURL[teller]=token;
                    teller++;
                else
                    teller--;
            coordinatesFileURL="";
            for(int i=0; i<teller-1;i++)
                coordinatesFileURL+=stringURL[i]+"/";
            coordinatesFileURL+=stringURL[teller-1];
        }

  • Relative path for files

    hi all,
    I am making a small program that needs to store some of the users preferences in a text file. I want the text file to be in the jar when i am finished and in the same folder as the main class. I am having a problem though with writing to a reading the file in a relative path. when i use "args.txt" it reads to the c:\args.txt and not the folder in which the program runs. Same thing with "\\args.txt" and "/args.txt". Any help? Thanks! :)

    If your file is in the same directory as the program the relative path is simply the file name : "args.txt". Also possible is "./args.txt".
    Keep in mind though that you can't write to a file in a jar, and even reading it is more complicated than with the ordinary I/O classes.
    Look up the getResourceAsStream method in the API (I think it's a method of the ClassLoader class).

  • Is Image File path of  Menus element support relative Path?

    hi,all
    absolute path is OK!
    but relative path no support!
    how to support it?
    thanks
    tony

    Hi Tony,
    The image file does support relative path but it requires a little coding.
    Please have a look at this thread:
    https://forums.sdn.sap.com/click.jspa?searchID=3854863&messageID=1041573
    Kind Regards,
    Owen

  • Absolute path of a file specified in a relative path

    Hello,
    If I refer to a file using a relative path, what will its absolute path be? How can I change it?
    Thanks.

    File file = ...
    String absPath = file.getAbsolutePath();

  • After forward, relative paths images are not displayed

              Hi,
              I have two web archives (war1.war, war2.war) and a jar with
              common code (jar.jar). war1.war contains jsp1.jsp and
              servlet1.class, jar.jar contains common.class, and war2.war
              contains jsp2.jsp.
              The user brings up jsp1.jsp in a browser and clicks a button
              which invokes servlet1.class (via post). In turn, servlet1.class
              invokes method forwardTo(...) of the common.class which brings
              up jsp2.jsp in user's browser. In the forwardTo(...) method I am
              using the servletContext for war1.war to get a dispatcher on
              which I then apply forward.
              The problem that I am seeing is that the images (.gif) in
              jsp2.jsp are not displayed at all. They are defined in the jsp
              file using a relative path as img="images/img.gif". It is as if
              the web server gets confused and does not know that the images
              should be based in the war2 application and is looking for them
              in the war1 application.
              I do not want to store the absolute path in the definition of
              the image (i.e., img="war2/images/img.gif").
              I am using WLS6.0sp1. What could be wrong?
              Thanks,
              Vladimir
              

    maybe try this
              instead of
              img="images/img.gif"
              try
              img="<%=request.getContextPath()%>/images/img.gif"
              "Vladimir" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Hi,
              >
              > I have two web archives (war1.war, war2.war) and a jar with
              > common code (jar.jar). war1.war contains jsp1.jsp and
              > servlet1.class, jar.jar contains common.class, and war2.war
              > contains jsp2.jsp.
              >
              > The user brings up jsp1.jsp in a browser and clicks a button
              > which invokes servlet1.class (via post). In turn, servlet1.class
              > invokes method forwardTo(...) of the common.class which brings
              > up jsp2.jsp in user's browser. In the forwardTo(...) method I am
              > using the servletContext for war1.war to get a dispatcher on
              > which I then apply forward.
              >
              > The problem that I am seeing is that the images (.gif) in
              > jsp2.jsp are not displayed at all. They are defined in the jsp
              > file using a relative path as img="images/img.gif". It is as if
              > the web server gets confused and does not know that the images
              > should be based in the war2 application and is looking for them
              > in the war1 application.
              >
              > I do not want to store the absolute path in the definition of
              > the image (i.e., img="war2/images/img.gif").
              >
              > I am using WLS6.0sp1. What could be wrong?
              >
              > Thanks,
              > Vladimir
              >
              

  • Using relative path for in file/ftp adapter

    Hi All,
    How to have a relative path for file/ ftp adapter's inbound/outbound operation?
    Example: Consider $ORA_HOME = /home/oracle --> This environment variable can be different on different machines
    i want to drop a file in to $ORA_HOME/folder1/folder2 (Or poll for a file).
    <partnerLinkBinding name="FTP">
    <property name="wsdlLocation">FTP.wsdl</property>
    <property name="out_dir" type="LogicalDirectory">What do i write here???</property>
    <property name="retryInterval">60</property>
    </partnerLinkBinding>
    if i cant configure this in partner link section or in activation agent sction, how else do i achieve this?
    i am using 10.1.3.* version.
    Thanks in advance.
    Roshan.

    You can achive it using the deployment scripts if the directory is changing on the basis of the environment
    If you want to change at run time than you can use the jca properties to set using the variables at runtime.
    Regards,
    Ajay

  • Relative path to file in servlet class file

    Hello,
    I have several classes running as a Tomcat Servlet on my server. However, I have one class that I would like to access a file on the server.
    The problem is, what path do I use? I want to use a relative path as the servlet might be moved and I don't want to recompile each time the servlet is moved. For instance, I placed the file in the servlet directory under webapps in the same level with the WEB-INF directory. However, using "../../text.txt" does not seem to access it.
    What path should I use?
    Thanks in advance.
    Chris

    This is what I have done:
         String FS = System.getProperty("file.separator");
         String ctx = getServletContext( ).getRealPath( "" ) + FS;
         URL url = new URL("file", "", ctx +   "somefile.txt");
         //Create a BufferedReader for reading the inputstream.
         BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));This gets you back to the "root", or one level above WEB-INF. Add the folder name where the file is located. As in      URL url = new URL("file", "", ctx +   "theFolder/somefile.txt");HTH,
    WalkGood

  • Relative path for HTML file

    Hi ,
    This is my requirement. In the ESS Personal information overview page, I can add a HTML file to the additional information section.
    I have created a HTML file by creating a web module and enterprise application and deployed the same through NWDI.
    I declare a resource wher ei mention the path. Here i specifed the complete path of the html file ... like
    http://hostname:portname/addinfo/addinfo.html.  Which i know is a wrong thing to do since when i move the html filel to the production system it will still be accessing the html file in the dev system.
    How do i give the relative path here so that the html file accessed is from the production system when we  go-live.
    Please suggest.
    regards
    sam

    Hi,
    One simpler solution is to use an AppIntegrator iView, as explained in the weblog <a href="https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2786">Integrating your Web Front-ends into the SAP Enterprise Portal using the Application Integrator</a>. It worked well for us.
    You can remove the user authentication part in the portalapp.xml if you don't need it.
    Regards,
    Martin

  • Relative Path for Attach menu forms or icon file

    How should i able to provide relative path while
    attaching Forms,menu or icon files in the Form application.
    So that it can be easily portable
    Thanx in advance
    Upendra

    You can use Regedit and do it manually. I am not sure but it seems to me that using Software Packager for deploying application can also change registry environment variables.

  • Relative path for servlet property file.

    I have the following java file. When I use the absolute path for the configFile, it works. I would like to know how I could use it as relative path as in installation, the name of the directory could change.
    How do I fix the problem? Thank you.
    ---------------------- LoadProperties.java ----------------
    import java.util.*;
    import java.io.*;
    public class LoadProperties {
    private String driver="";
    private String dbURL="";
    private String login="";
    private String password="";
    static public void main(String[] args) {
    LoadProperties lp = new LoadProperties();
    } // main
    public LoadProperties() {
    //String configFile = "C:/1LMS/web-app/WEB-INF/config/db.properties";
    String configFile = getClass().getResource("config/db.properties").toString(); <--- This line could not find the db.properties file.
    Properties Prop = new Properties();
    try {
    FileInputStream configStream = new FileInputStream(configFile);
    Prop.load(configStream);
    configStream.close();
    } catch(IOException e) {
              System.out.println("Error: Cannot laod configuration file ");
    driver =Prop.getProperty("driver");
         dbURL = Prop.getProperty("dbURL");
         login = Prop.getProperty("login");
    password = Prop.getProperty("password");
    printResult();
    } //Load Property
    private void printResult() {
         System.out.println("Driver = " + driver);
         System.out.println("dbURL = " + dbURL);
         System.out.println("Login = " + login);
    System.out.println("PSWD = " + password);
    } // class

    hi there,
    had the same problem... you need to use following API:
    http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)
    In your case something like that:
    // get the servlet context
    ServletContext context = getServletContext();
    // directory name where the file is located
    String realPath = context.getRealPath("/config");
    // get real path to your file
    String propertyPath = real+"filename.txt";
    hope that helps!!
    minu

  • Can any one suggest me how can I use relative path inside SSIS pacakge to access config file ?

    Can any one suggest me how can I use relative path inside SSIS pacakge to access config file ? Please help me as its urgent.THanks for your help in advance.

    Hi Jay,
    SSIS can only recognize the absolute path of a XML Configuration file, the relative path is not supported. Furthermore, if the XML Configuration file is already generated, we can use the Environment variable package configuration type instead so that
    SSIS runtime automatically looks for the configuration file from the path defined in the environment variable. This is convenient when we need to deploy a package to different environment. We only need to define the environment variable for package configurations
    once on each server, and then the variable can be used by all the packages on this server.
    Regards,
    Mike Yin
    TechNet Community Support

  • Creation of file using relative path

    I am working on JSP
    I want to create a file object by passing a relative path as parameter to
    File f = new File("<relative path>");
    i encounter the following error
    "it says server cannot find the file in the path specified."
    I have searched the forums but not able to get any relevant expalination.
    Its an urgent requirement. So please reply. Thanks in advance.

    I notice that servletContext.getRealPath()
    returns path from root directory to the ../webapps/examples folder
    am i correct or it can get real path for any file residing in any subfolder
    like ../webapps/examples/a/df/a.txt ?

Maybe you are looking for

  • Mysterious but clever facility on Macbook rotating photos for display.

    I have a question that has puzzled me for days and I can't find out how or why the Macbook does this. I took a photo on my digi camera in "Portrait" orientation or mode in other words I turned the camera sideways on to take a photo of a tall building

  • F-04 ( Transfer Postings ) - Reg

    Hi gurus this is ramki Advance Payments through Cash The FBCJ is not permitting to post Spl Gl transactions for Vendors, if iam post that Spl Gl as normal item in FBCJ, how  can i  transfer the entry from normal reconciliation account to Spl Gl Recon

  • Hard drive icon

    The hard drive icon that is displayed in the top right corner of my computer has always displayed Macintosh HD underneath it. However, today when I came home and sat down at my computer it now displays \\b\b\\ underneath it. Anyone know the reason wh

  • Cursor issue in 2012 v 2008r2

    Hi there,  we're executing the same stored procedure against identical databases on sql 2008r2 and 2012. The sp contains a cursor and runs quickly (3 mins) on 2008r2, yet continues to run on 2012. We've checked everything in terms of hardware, networ

  • Business Rules on super-sub types

    We are currently in the process of modeling business rules. We have some super-subtype entities in our datamodel. We also have business rules on the super-type as wella as the sub-types. What name for these BR's should we use, more specific which ent