File exists always false

I'm making a mobile app for iOS and I have files in both the applicationDirectory (inside the app) and the cacheDirectory.
No matter what I do a check on file.exists always returns false even though it is there - it's a video and it can play so it's there alright.
What is going on?
I have a string representing the path eg. "/assets/video.mp4"
var f:File = File.applicationDirectory.resolvePath(filePath);
trace(f.exists) //false

When I trace the nativePath of the file I am trying to find it shows "C:\Users\User\AppData\Roaming\Arakaron.debug\Local Store". This is the exact path I am following in Explorer. Now, instead of applicationStorageDirectory I can do documentsDirectory and it reads that the file is in fact there. With the applicationStorageDirectory it only registers that the file exists after I copy from the embedded db file. 

Similar Messages

  • File.exists returns false

    File.exists returns false if the File object represents a symlink that is pointing to a non existing file.
    How can I make it return true? I am using File.exists in a condition to
    check if a symlink exists before calling File.delete.
    I am using JDK 1.1.8.
    Any help is appreciated.
    Anil

    Interesting. But it doesn't hurt to call delete() even the File doesn't exist, does it? Could you clarify why you need to confirm that before calling delete()?
    PC

  • File Exists Always returning false

    I am using the File.applicationStorageDirectory.resolvePath("myData.db") to reference the location of my SQLite DB file. When I browse to the folder in question I can see that the file is in fact there, however and traces I implement of dbfile.exists is false. It only ever returns true should I use my defaultdb and CopyTo the file of the myData.
    What seems to be the issue here?

    When I trace the nativePath of the file I am trying to find it shows "C:\Users\User\AppData\Roaming\Arakaron.debug\Local Store". This is the exact path I am following in Explorer. Now, instead of applicationStorageDirectory I can do documentsDirectory and it reads that the file is in fact there. With the applicationStorageDirectory it only registers that the file exists after I copy from the embedded db file. 

  • File.exists() returns false for existing file, help :)

    Hi all,
    I'm having the STRANGEST behavior... I'm working on a simple DNS management system, and before I overwrite a zone file, I want to check if it exists... but exists() is returning false even when the file exists.
    Here is my code snippet:
    finest( "Checking the existance of "+filename ) ;
    File zoneFile = new File( filename ) ;
    if ( zoneFile.exists() ) {
        finest( "Zone File "+zoneFile+" already exists." ) ;
        throw( new ZoneFileExistsException( fqdn ) ) ;
    else {
        finest( "Creating Zone File "+zoneFile ) ;
        ...It's producing this in the log (I cut off the timestamp parts):
    Checking the existance of /opt/DNS/db.testingbutler222.com
    Creating Zone File /opt/DNS/db.testingbutler222.com
    but...
    # ls -l /opt/DNS/db.testingbutler222.com
    -rw-r--r-- 1 root other 733 Aug 27 19:23 /opt/DNS/db.testingbutler222.com
    So... as you can see, the file CLEARLY exists... what the heck am I doing wrong or misunderstanding? This can't really be a bug in File, can it?
    Kenny Smith

    Hi,
    Thanks for your response, but as I showed in my first post, I'm using absolute paths. My log file contains this:
    Checking the existance of /opt/DNS/db.testbutler222.com...
    Existance of /opt/DNS/db.testbutler222.com=false
    # ls -l /opt/DNS/db.testbutler222.com
    -rw-r--r-- 1 root other 695 Aug 29 12:17 /opt/DNS/db.testbutler222.com
    I don't understand what is happening... I wrote a separate class that just tests the existance of a file, and that one is reporting the existance correctly.... (the source code is found in the second post above) I don't understand why my servlet code can see the file.
    I have jakarta-tomcat running as root, and the file I'm checking was created by the same servlet. I've double checked permissions and such, just to make sure it wasn't that.. but it's still not working.
    I even added code to create a FileReader from the file, that way if it throws a FileNotFoundException, I would know the file doesn't exist... and even though the file does exist, it throws the exception. :(
    Kenny

  • File.exists() returning false eventhough in reality the file exists

    Hi,
    I am trying to create a PDF file using FDFMerge software.
    For creating the PDF file, I need to execute a shell script from command-line, which I am doing using "Runtime.exec".
    ( I opted for this 'RunTime.exec' approach so as to read the output generated by the shell script.)
    After executing the shell script and reading all the output generated by the process, I am trying to check if the PDF file exists in the location the process created.
    When I do File.exists() its returning me "false" eventhough in reality the file exists.
    Any guess, why this is happening?
    Thanks in advance.
    -Sudheer

    Hi,
    I am trying to create a PDF file using FDFMerge
    software.
    For creating the PDF file, I need to execute a shell
    script from command-line, which I am doing using
    "Runtime.exec".
    ( I opted for this 'RunTime.exec' approach so as to
    read the output generated by the shell script.)
    After executing the shell script and reading all the
    output generated by the process, I am trying to check
    if the PDF file exists in the location the process
    created.
    When I do File.exists() its returning me "false"
    eventhough in reality the file exists.
    Any guess, why this is happening?
    Thanks in advance.
    -SudheerI know the following method works for checking if a file exists...
    public LineCounterB1()
              super( "GUI File reader" );
              tField = new JTextField("c:..\\FileScanner\\source\\test\\LineCounterB1.java");
              tField.setBackground(backColor1);
              tField.setForeground(foreColor1);
              tField.addActionListener( this );
    public void actionPerformed( ActionEvent ae )
              File name = new File( ae.getActionCommand() );
              if( name.exists() )
                   oArea.setText("FOUND " + name.getName() + "\n" +
                        (name.isFile() ? "File\n" : "Not a File\n" ) +
                        (name.isDirectory() ? "Directory\n" : "Not a Directory\n" ) +
                        (name.isAbsolute() ? "Absolute path\n" : "Not Absolute path\n" ) +
                        "Last modified" + name.lastModified() );
                   if( name.isFile() )
                        try
                             BufferedReader reader = new BufferedReader( new FileReader( name ) );
                             StringBuffer buffer = new StringBuffer();
                             String text = null;
                             oArea.append("\n\n");
                             while((text = reader.readLine())!=null)
                                  buffer.append(text + lineSep);
                             oArea.append(buffer.toString());
                        catch( IOException ioE)
                             JOptionPane.showMessageDialog(null,"Oooooo...");
                        //S7 scanner7 = new S7(/**name**/);                                        
                   else if( name.isDirectory())
                        String directory[] = name.list();
                        oArea.append("\n\nDir contents:\n");                    
                             for( int i=0; i<directory.length; i++)
                                  oArea.append( directory[i] + "\n");
              else
                   JOptionPane.showMessageDialog(null, "No such file or directory.");
         }

  • File.exists() returns false even when the file exists

    hi,
    the exists() function of java.io.File function returns false even when the file exists on the file system. why is this? i checked the path of the file which gives me the correct path, but exists returns false. can anyone help?

    post some of the code you�re using - then maybe I can help you out
    //Anders

  • File.exists()  returs false even the file is present in the specified path

    Hi,
    When i try to run the following program which checks whether the file exists in the given path or not
    public class FileCheck {
    public static void main(String[] a){
    String str = a[0];
    File f = new File(str);
    if(f.exists())
    System.out.println("File Exists ");
              else
         System.out.println("File does not Exists ");
    So on solaris 10(korean) we have file named in korean language under "usr" directory. When i try to run the above program on solaris 10(Korean) using the default jre (1.5)with the parameter "/usr/file name in korean language" .The output of the program is "File Exists"
    And when i run the same class file using the jre (1.6) which is installed in our application which is an english version with the same parameter ""/usr/file name in korean language"
    The output of the program is "File does not exists".
    And this problem is only with the files which contain the name in korean language.
    So do we need to set any properties for the jre in our application to work for files which are named in korean language. Any help will be highly appreciated.
    Thanks,
    GPK
    Edited by: gpk_04 on Nov 11, 2008 1:46 PM
    Edited by: gpk_04 on Nov 11, 2008 1:57 PM

    My guess is that Java 5 and 6 are picking up the file system encoding differently. As a consequence, the JVM is either:
    1. reading and converting your command line argument incorrectly, or
    2. reading and converting the file name from the file system incorrectly.
    Write a quicky, short app that prints out the file encoding of your host. Run this under 5 and then 6. Do you see different outputs?

  • Check if file exists returns false. File is in system32

    I'm having a problem detecting if a file exists which was simply copied to the system32 directory.  I tried moving the file to various other directories and simply using a vi with the "Check if file or folder exists" action.  I've narrowed it down to not being able to find the file if I copy it to either c:\windows or c:\windows\system32. 
    I thought this could be a permissions issue, but did my best to assign the user name full control of the folders.
    Another interesting thing is if I make the file input a control and click on the "folder" icon to open a list of files, I cannot see the newly copied files in system32 directory either.  Very strange.
    This is on a Dell PC, Windows 7 professional/Labview 2010 SP1 (note I am running the vi. as an executable on this machine).  Could it be some setting in my project build?
    Solved!
    Go to Solution.

    If you're using Windows 7 64-bit, it may be related to the problems the user was having here:
    http://forums.ni.com/t5/LabVIEW/Problem-Using-quot-msg-quot-command-with-quot-System-Exec-vi/m-p/153...
    It may be that the LabVIEW functions are 32-bit and are getting redirected.

  • False File.exists; flex cannot open SQLite.db file

    I have a program that uses an SQLite database. Instead of creating and importing the database, the sqlite databse already exists, with the data.
    I am trying to open it and read the information (select* from table - for example); But nothing i do seems to work.
    The error I am getting is: 'Error #3125: Unable to open the database file.', details:'Connection closed.', operation:'open', detailID:'1001'. I have checked the path repeatedly, The file exists. I run flash builder as administrator (win7).
    code:
    I have moved the database file all around. In the final version of the program, the database will be stored in a seperate drive on a network (Z:/database.db, for example) So i need to use the absolute path; although i have tried others (application storage directory, etc)
    var dbFile:File = new File("C:\Users\Public\Documents\graduates.db");
    trace('exists:' + dbFile.exists);
    //above being the important bit.
    dbStatement = new SQLStatement();
    dbStatement.itemClass = Grad;
    aluDB = new SQLConnection();
    dbStatement.sqlConnection = aluDB;
    aluDB.addEventListener(SQLEvent.OPEN, onDatabaseOpen);
    aluDB.addEventListener(SQLErrorEvent.ERROR, errorHandler);
    aluDB.open(dbFile);//error occurs here, of course.
    can anybody help me figure out why this error is occuring? Or even just a different method of opening the file?

    Hello,
    I have an Oracle Express Edition 10g running on
    Redhat Enterprise Linux 4 server.
    I have an Oracle database file which is 2.1 GB in
    size. I am not able to open this file using the
    application or the Oracle sql developer. The error
    message that I get is:
    ORA-01110: data file 5:
    '/usr/lib/oracle/xe/oradata/XE/service_3_0.dbf'
    ORA-27041: unable to open file
    Linux Error: 13: Permission denied
    I think this has to do with the fact that since it is
    not a 64-bit Linux but a 32-bit Linux, it does not
    support files larger than 2GB. What do you think I
    should do to tackle this problem?
    Best Regard
    ThayalanThat's interesting! I had no problems with opening files 32767MB in size on the very same 32 bit RH EL 4.0. How did you conclude that your file is too large, based on the error message which reads "Linux Error: 13: Permission denied"? Have you tried reading the manual page for the "open" system call and see when does it return EACCESS (error 13), found in /usr/include/asm-i386/errno.h. My man page for open says the following:
    ERRORS
    EACCES The requested access to the file is not allowed, or search per-
    mission is denied for one of the directories in the path prefix
    of pathname, or the file did not exist yet and write access to
    the parent directory is not allowed. (See also path_resolution(7).)
    What lead you to the conclusion that your file is too big? Do you have an access to a system administrator who knows how to use "strace"? If your system admin doesn't know how to use "strace", he too deserves waterboarding.

  • Java.io.File exists() problem

    I have a web application deployed on a Windows 2000 server and am running Tomcat 4. I want to check for the existence of an image file before displaying it and am trying to use the java.io.File.exists() method. I am using the following code:
    String strPicUrl = "/images/thefile.jpg"; //Actual value comes from database
    File theFile = new File(application.getRealPath(strPicUrl));
    out.print("File Exists: " + theFile.exists() + "<br>");the actual file name in this example is "/images/theFile.jpg", and theFile.exists() always returns true if the file is there, but differs in case. If I try to display the image it doesnt show up under Tomcat because aliasing is turned off by default. I need to find a way to determine if a file exists based on actual case matching. This way if I get a "true" value, the file should be accessible and/or viewable via the JSP engine.
    Any ideas how to perform a case sensitive "exists()" regardless of the underlying OS file system?

    This looks awesome, but when I tried to implement it without creating a class, I get a method error. Here is the code below:
    String theDir = "C:\\Dir\\Subdir\\";
    FileFilter theFilter = new FileFilter() {
         private String _theFile = null;
         public boolean accept(File file)
              if (file.isDirectory()) return false;
              String fileName = file.getName();
              if (fileName.endsWith(_theFile)) return true;
              return false;
         public void setTheFile(String theFileParam)  
              _theFile = theFileParam;  
    theFilter.setTheFile("theFile.jpg");When I run this I get the following error:
    [javac] ...blah error stuff...
    [javac] cannot resolve symbol
    [javac] symbol : method setTheFile (java.lang.String)
    [javac] location: interface java.io.FileFilter
    [javac] theFilter.setTheFile("theFile.jpg");
    Since I am invoking the FileFilter object directly and not instantiating it in a class, is that causing the error or am I declaring "setTheFile()" wrong?

  • File exists() with dirs like "docume~1" and other shorted paths on windows

    Hello All
    I've been having troubles when using "shorted" paths like "C:\docume~1\...."
    Unfortunatelly i have to parse the output of another program which gives me the way "docume~1" instead of "documents and settings"
    The thing is that when i use something like
    File path = new File ("C:\docume~1\....");
    boolean out = path.exists();
    out is always false for this kind of paths, while when other normal paths i have no problems. Is there any way to "translate" it on the fly, or make this reduced names to be recognized by Java?

    8.3 notation using "~" works for me.
    File path = new File ("C:\docume~1\....");Might be a typo, but make sure to escape the backslash in string constants, i.e.:
    File path = new File("C:\\docume~1\\...");

  • Dialog prompt and check if file exists, and use the result of dialog

    I have this working script and I want to change the way it behaves.
    I want a dialog to come up, Do you want to skip or replace existing files.
    Then the result  of the dialog to be used in the reast of the script.
    I've added it in the script where I need to use it. in noce big letters, hopefully its not a big job.
    Many thanks
    property type_list : {"8BPS"}
    property extension_list : {"psd"}
    script o
              property theseNames : {}
    end script
    -- empty log file
    do shell script "echo  'Files not processed in Photoshop :'  > ~/Desktop/LogPhotoshopError.txt"
    set noError to true
    --Setup list of folders and process details of folders
    set dtF to paragraphs of (do shell script "ls -F ~/Desktop | grep '/' | cut -d'/' -f1")
    set tc to (count dtF)
    repeat with i from 1 to tc
              set folderName to item i of dtF --<:  is the folder name, no need to use text item delimiters -->":"
              if folderName does not start with "2_" and folderName does not start with "Hot" and folderName does not start with "Press" and folderName does not start with "Design" and folderName does not start with "Keywords" and folderName does not start with "Season" and folderName does not start with "Sue" and folderName does not start with "Design" then
                        set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
                        set FolderEndName to last text item of folderName
                        set brandName to first text item of folderName
                        set my text item delimiters to "_PSD"
                        set weekNumber to first text item of FolderEndName
                        set my text item delimiters to oldTID
                        set theFolder to ("Hal 9000:Users:matthew:Desktop:" & folderName)
      --set up names to destination folders and create locally based on brand name and week number
                        set this_local_folder to "Images:2012-2013"
                        set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
                        set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
                        set localBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", localBrandFolder)
                        set localBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", localBrandFolder)
                        set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
                        set this_Network_folder to "GEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
                        set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
                        set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
                        set website_images to "GEN:Website_Images:"
      --set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
                        set this_ftp_folder to "pulse:"
                        set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
                        set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
                        set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
                        set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
      --at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
      --use the result for the if file exists?
                        display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
      --taking the folder identify which process it must follow.
                        if brandName is equal to "BH" then
                                  try
                                            tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
                                  on error
                                            set o's theseNames to {} -- no psd files or "8BPS"
                                  end try
                                  set numOfNames to (count o's theseNames)
                                  repeat with j from 1 to numOfNames
                                            set thefile to theFolder & ":" & (item j of o's theseNames)
      --    B H   Folder Photoshop Process
      --if thefile exists in the folder localBrandFolder_PSD then do the result of dialog.
      --"Skip" the file and move on to next
      --If "replace" continue the rest of the script.
                                            tell application "Adobe Photoshop CS5.1"
      -- I remove the command activate, Photoshop stay in background
                                                      set ruler units of settings to pixel units
                                                      try
      open (alias thefile) showing dialogs never
                                                                set origName to name of current document
                                                                set myOptions to {class:JPEG save options, quality:12}
                                                                set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
                                                                tell current document
      --If the quick mask mode has been left on then delete the channel Quick Mask
                                                                          if (quick mask mode) then delete channel ¬
                                                                                    "Quick Mask"
      --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                                                          if (exists layer "Original Layer") then ¬
                                                                                    tell layer "Original Layer" to set name to "Original Image"
      save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                                                                          (delete layer "Original Image") flatten
      resize image resolution 300 resample method none
      --sharpen image
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      save in (localBrandFolder_High_Res & name) as JPEG with options myOptions without copying
      --get file path, return path of the JPEG file, work with (without copying)
      -- (with copying) : it return path of PSD file
                                                                          set newFile to file path --( return path of type alias )
      -- duplicate file using the Finder  -->on duplicateFile(..)
                                                                          my duplicateFile(newFile, {ftpBrandFolder_High_Res})
      --Prepare for Low RES by resetting image history
                                                                          set current history state to history state 3
                                                                          flatten
                                                                          resize image width 1348
      resize image resolution 300 resample method none
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      --add save to lowResFolder with same options
      save in (localBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
                                                                          set newFile to file path
                                                                          set newFile2 to newFile as string -- for testing end of name
                                                                          if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" then -- exclude website_images
                                                                                    my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res})
                                                                          else
                                                                                    my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res, website_images})
                                                                          end if
      close saving no
                                                                end tell
                                                      on error
                                                                set noError to false
                                                                my myLogs(thefile) -- write path to log file in Desktop
                                                                try
      close saving no --if exists, close current document
                                                                end try
                                                      end try
                                            end tell
                                  end repeat
      --End BH
    -- else if and the rest of the script.....
    end repeat
    if not noError then do shell script "/usr/bin/open  ~/Desktop/LogPhotoshopError.txt'"
    on myLogs(t)
              try
                        do shell script "echo " & (quoted form of t) & ">> ~/Desktop/LogPhotoshopError.txt'"
              end try
    end myLogs
    on duplicateFile(tFile, foldersPath) -- tFile is an alias, foldersPath is a list of folder
              tell application "Finder" to repeat with folderPath in foldersPath
                        with timeout of 200 seconds -- adjust it,  error if the copy  is longer that 200 seconds
      duplicate tFile to folder folderPath with replacing
                        end timeout
              end repeat
    end duplicateFile
    on getFolderPath(tName, folderPath)
              tell application "Finder" to tell folder folderPath
                        if not (exists folder tName) then
                                  return (make new folder at it with properties {name:tName}) as string
                        else
                                  return (folder tName) as string
                        end if
              end tell
    end getFolderPath
    tell application "Finder"
              open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"
    end tell

    Hi,
    I think that's what you want.
    I put the dialog in the beginning, so it does not appear to each folder, otherwise put it in the loop as it was originally.
    property type_list : {"8BPS"}
    property extension_list : {"psd"}
    script o
          property theseNames : {}
    end script
    -- empty log file
    do shell script "echo  'Files not processed in Photoshop :'  > ~/Desktop/LogPhotoshopError.txt"
    set noError to true
    --at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
    --use the result for the if file exists?
    display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
    set skipFiles to (button returned of the result) is "Skip (Faster)"
    --Setup list of folders and process details of folders
    set dtF to paragraphs of (do shell script "ls -F ~/Desktop | grep '/' | cut -d'/' -f1")
    set tc to (count dtF)
    repeat with i from 1 to tc
          set folderName to item i of dtF --<:  is the folder name, no need to use text item delimiters -->":"
          if folderName does not start with "2_" and folderName does not start with "Hot" and folderName does not start with "Press" and folderName does not start with "Design" and folderName does not start with "Keywords" and folderName does not start with "Season" and folderName does not start with "Sue" and folderName does not start with "Design" then
                set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
                set FolderEndName to last text item of folderName
                set brandName to first text item of folderName
                set my text item delimiters to "_PSD"
                set weekNumber to first text item of FolderEndName
                set my text item delimiters to oldTID
                set theFolder to ("Hal 9000:Users:matthew:Desktop:" & folderName)
                --set up names to destination folders and create locally based on brand name and week number
                set this_local_folder to "Images:2012-2013"
                set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
                set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
                set localBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", localBrandFolder)
                set localBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", localBrandFolder)
                set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
                set this_Network_folder to "GEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
                set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
                set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
                set website_images to "GEN:Website_Images:"
                --set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
                set this_ftp_folder to "pulse:"
                set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
                set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
                set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
                set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
                --taking the folder identify which process it must follow.
                if brandName is equal to "BH" then
                      try
                            tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
                      on error
                            set o's theseNames to {} -- no psd files or "8BPS"
                      end try
                      set numOfNames to (count o's theseNames)
                      repeat with j from 1 to numOfNames
                            set thefile to theFolder & ":" & (item j of o's theseNames)
                            --    B H   Folder Photoshop Process
                            tell application "Finder" to set b to exists file (localBrandFolder_PSD & item j of o's theseNames)
                            if b and not skipFiles then -- file exists and "replace" (continue the rest of the script).
                                  tell application "Adobe Photoshop CS5.1"
                                        -- I remove the command activate, Photoshop stay in background
                                        set ruler units of settings to pixel units
                                        try
                                              open (alias thefile) showing dialogs never
                                              set origName to name of current document
                                              set myOptions to {class:JPEG save options, quality:12}
                                              set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
                                              tell current document
                                                    --If the quick mask mode has been left on then delete the channel Quick Mask
                                                    if (quick mask mode) then delete channel ¬
                                                          "Quick Mask"
                                                    --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                                    if (exists layer "Original Layer") then ¬
                                                          tell layer "Original Layer" to set name to "Original Image"
                                                    save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                                                    (delete layer "Original Image") flatten
                                                    resize image resolution 300 resample method none
                                                    --sharpen image
                                                    filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
                                                    save in (localBrandFolder_High_Res & name) as JPEG with options myOptions without copying
                                                    --get file path, return path of the JPEG file, work with (without copying)
                                                    -- (with copying) : it return path of PSD file
                                                    set newFile to file path --( return path of type alias )
                                                    -- duplicate file using the Finder  -->on duplicateFile(..)
                                                    my duplicateFile(newFile, {ftpBrandFolder_High_Res})
                                                    --Prepare for Low RES by resetting image history
                                                    set current history state to history state 3
                                                    flatten
                                                    resize image width 1348
                                                    resize image resolution 300 resample method none
                                                    filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
                                                    --add save to lowResFolder with same options
                                                    save in (localBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
                                                    set newFile to file path
                                                    set newFile2 to newFile as string -- for testing end of name
                                                    if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" then -- exclude website_images
                                                          my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res})
                                                    else
                                                          my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res, website_images})
                                                    end if
                                                    close saving no
                                              end tell
                                        on error
                                              set noError to false
                                              my myLogs(thefile) -- write path to log file in Desktop
                                              try
                                                    close saving no --if exists, close current document
                                              end try
                                        end try
                                  end tell
                            end if -- else "Skip" the file and move on to next
                      end repeat
                      --End BH
                end if
          end if
    end repeat
    if not noError then do shell script "/usr/bin/open  ~/Desktop/LogPhotoshopError.txt'"
    on myLogs(t)
          try
                do shell script "echo " & (quoted form of t) & ">> ~/Desktop/LogPhotoshopError.txt'"
          end try
    end myLogs
    on duplicateFile(tFile, foldersPath) -- tFile is an alias, foldersPath is a list of folder
          tell application "Finder" to repeat with folderPath in foldersPath
                with timeout of 200 seconds -- adjust it,  error if the copy  is longer that 200 seconds
                      duplicate tFile to folder folderPath with replacing
                end timeout
          end repeat
    end duplicateFile
    on getFolderPath(tName, folderPath)
          tell application "Finder" to tell folder folderPath
                if not (exists folder tName) then
                      return (make new folder at it with properties {name:tName}) as string
                else
                      return (folder tName) as string
                end if
          end tell
    end getFolderPath
    tell application "Finder"
          open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"
    end tell

  • File exists but program can't open it

    G'day all.
    I am trying to port some fortran programs from a True64 environment into Sun v9/SunStudio 11. On the alpha it has no problems, but on the Sun it can't open a file with a name that is only 78 characters long. The Fortran User's guide states that the maximum length for a file name is 1024 characters.. The file most certainly exists and is readable to the user: stat gives:
    silo@eclipse /silo1/tech1/install/bin -> stat /silo1/tech1/install/import/rtmet/NCC/dayClim/200706/2007062720070627.dc
      File: `/silo1/tech1/install/import/rtmet/NCC/dayClim/200706/2007062720070627.dc'
      Size: 133170         Blocks: 288        IO Block: 8192   regular file
    Device: 1d8005ah/30933082d     Inode: 110852      Links: 1
    Access: (0664/-rw-rw-r--)  Uid: ( 3953/sielewiczj)   Gid: (  700/    ciss)
    Access: 2008-07-23 12:44:00.533357000 +1000
    Modify: 2008-07-04 14:21:00.107423000 +1000
    Change: 2008-07-08 09:27:39.322719000 +1000The compiled Fortran code (called from a wrapper script) however:
    [07/23/08 12:46]: silo_dc_import_wrapper starting
    Determining dates to process
    Now starting to process Silo 1998
    aah, how sweet - found file /tmp/silo/DC_filelist                              
    About to check  /silo1/tech1/install/import/rtmet/NCC/dayClim/200706/2007062720070627.dc                                              
    In file not Found  /silo1/tech1/install/import/rtmet/NCC/dayClim/200706/2007062720070627.dc                                                Bye
    ******  FORTRAN RUN-TIME SYSTEM  ******
    Error 2:  No such file or directory
    Location:  the OPEN statement at line 770 of "dc_importer.f90"
    Unit:  12
    File:   /silo1/tech1/install/import/rtmet/NCC/dayClim/200706/2007062720070627.dc
    AbortNote that it could succesfully open the file /tmp/silo/DC_filelist... The code in question is:
    ! Problematic snippet from much longer program..
             integer*4 eof, ymd
             character*120 in_file, filelist
             logical file_exists
             file_exists = .TRUE.
             filelist = params(2)
             inquire(file = filelist,  exist = file_exists)
             if ( file_exists == .FALSE. ) then
               write(*,'(3a)') 'Not Found ', filelist, ' Bye'
               return
             endif
             print *, "aah, how sweet - found file ", filelist
             open ( unit=11, file=filelist, status='OLD' ) ! THIS succeeds (/tmp/silo/... short filename)
             read ( 11, "(i8, A120)", iostat = eof) ymd, in_file
             do while ( eof == 0 )
                write (*,'(2a)') "About to check " , in_file
               inquire(file = in_file,  exist = file_exists)
               if ( file_exists == .FALSE. ) then
                 write( *, '(3a)') 'In file not Found ', in_file, ' Bye'
    !             return (commented out to see if open also gives an error..)
               endif
             open ( unit=12, file=in_file(1:len_trim(in_file)) , status='OLD' ) ! THIS is where the program bombs out.
             end doI am stumped. Why would this bomb out? The file exists, is readable, the filename is << 1024 characters.. I've also tried to run this as the user who owns the file, to no avail. Any suggestions, please?
    Cheers,
    Tony

    First, check to be sure the program has read and execute access on every directory in the path to the file.
    If the directory permissions are all OK, run your program under truss:
    truss -f -a -vall -o /output/file/name/here your.progam.hereThere should be something like a stat() and an open() call for that file shown as failing in your truss output file. Hopefully that will give you some more information.

  • Do not continue until a file exists in powershell

    Hi,
    I was wondering if there is a method in powershell to get it to 
    continually check whether a file exists and do not progress until it finds it.
    i.e
    DO WHILE  
    c:\flag.txt NOT EXISTS
    Wait 10 seconds
    END
    <Next command >
    So that the <next Command> section is only executed once it finds the file c:\flag.txt
    Is this possible?
    Thanks,
    Zoe

    I doubt that it would have been very helpful anyway.  The requirement was
    "check whether a file exists and
    do not progress until it finds it"
    so blocking is exactly what's called for.  Putting it into a background job is probably just going to trade checking of the file status for checking on the job status.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    My post was very helpful, indeed.
    Blocking any instance of an application (PowerShell in this case) is almost always a very bad decision (*) because it blocks the UI.
    Do you understand that a UI, when blocked cannot process any other command from user, just because the UI is blocked?
    ( Alright, Ctrl+Break can stop the process, and the terminate the PowerShell session too! )
    Your argumentation is proper of a non-programmer.
    Imagine the situation: you, the user, has a powerful computer at your finger tips, with last generation of MS server, which is running your smart PS script that's blocking (how many hours for?) your PS instance. In this case, you don't need a powerful computer,
    what you need is a better PowerShell scripter.
    Haven't heard of Star-Job?
    Spend sometime reading about it, it's worth the reading.
    ( Alright, your mvp friend seems never heard of it, when I look at the crap code he did using Star-Job in another thread. )
    The solution is very simple: Start a job to wait for whatever have to be waited; then, keep using the PS instance
    normally, and check once or another if the job is completed (or use another sync mechanism).
    This is smart!
    Blocking the UI is since ever, not smart.
    (*) except very specific situations; fortunately, current computers are preemptively multitask.
    I understand it blocks the UI, but we don't have any indication in the question that this is going to be used in an interactive session or that the OP doesn't know about background jobs.  If it's going to have to monitor/wait for an extended period
    of time it could well be being implemented as a scheduled task or job, or even as a persistent job.  No matter what the session environment is, some solution for implementing that blocking behavior will be needed to satisfy the stated requirements, and
    the posted solution will do that.
    The assumption is that the OP isn't smart enough to figure out or experienced enough to know that what they're asking for will block their interactive session while it waits for the file.  I don't see anything in the question to warrant that assumption. 
    If it's going to have to wait an arbitrarily long time, a permanent registered event might be a better solution than the time loop.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • File.exists() takes too long to return.

    Hi.
    I have written a program which checks to see if a particular shared file is present on a number of different computers. The path to the file is the same on all the computers.
    I construct the File with IP + path.
    Then I call file.exists()
    If the remote computer is on and the file is present, then 'true' is returned quite quickly. But if the file is not available then 'false' is returned but only after about 30 seconds. This is too long and I want to set some sort of time out for the method after about 3 seconds. So that if the file is not found before the timeOut time, 'false' will be returned.
    Is there any way I can do this???
    Thanks,
    Jim

    Hi,
    I am already using Threads, here is my code:
    public class FileExistsThread extends Thread {
         private File file;
         private long tryTime;
         private boolean exists;
         private boolean changed;
         public FileExistsThread(File file, long tryTime) {
              this.file = file;
              this.tryTime = tryTime;
         public void run() {
              new Thread() {
                   public void run() {
                        try {
                             Thread.sleep(tryTime);
                        } catch(Exception e) {}
                        exists = false;
                        changed = true;
              }.start();
              exists = file.exists();
              changed = true;
         public boolean fileExists() {
              start();
              while(!changed);
              return exists;
    }The Problem is that I cant close my program while a file.exists() method is still executing no matter what Thread it is in. Say I'm looking for a file which the program will take 30 seconds to establish is not available. Then for that 30 seconds my program will refuse to close. Sometimes it can be much longer than this.
    This is why I still need some sort of timeout mechanism.
    Any Ideas?
    Cheers,
    Jim

Maybe you are looking for

  • TS1702 credit card charged for iTunes yet no puchase

    My credit card has four charges for about $50.00, all on the same day from Apple iTunes with the same ID number as it lists on all my other (legitimate) purchases. I can't "report a problem" because I never received an email for these alleged purchas

  • SharePoint Products Configuration Wizard - Configuration Failed at step 10 of 10

    A little background information.  I am simply trying to create a SharePoint Server on my laptop.  I utilized the Microsoft Hyper-V Manager to create a Virtual Machine of which I have Windows Server 2012 R2 running.  I have installed the SharePoint pr

  • Same dimension in two different fact tables

    Hi, I have one same dimension in two different fact tables. I would like to know how BI server choose the fact table when I do a request in this dimension. I know that is always using the same fact table, but I would like to know why choose this tabl

  • How to convert a Hybrid Sup3 to a Native IOS Sup3

    I have redundant 6509's with currently 1 sup 3 board in each. The Sup3's are running Native mode. The Sups are not running redundant to themselves. If I lose a switch, I have to physically move cables from one switch to the other. I have just receive

  • Change file type to pdf

    How do I change file type to pdf with windows 8 without paying? I was able to do this with windows 7 without paying.