2 Replies Latest reply: Jul 5, 2009 3:48 PM by John.Kordas RSS

    CS3 folders with spaces in the name

    John.Kordas Community Member

      I'm having a slight issue with files that are in folders that have spaces in the folder name.

       

      For example the files is in the following location: /c/Hold/Test Image Folder/mondeo n rtu 41%.psd

       

      If I run the script it creates a folder called ScriptFolder in the location on the file and does a saveAs psd file into that folder but I get an error.

       

      General Photoshop error occured. This fucntionality may not ....ld\....\mondeo n 41%" because the file could not be found.

       

      If I change the folder "Test Image Folder" to "Test_Image_Folder" which is where the file is the script works.

       

      Here is the script any suggestions on how I can get around this?

       

      var myPsDoc = app.activeDocument;
      var justname = myPsDoc.name.split (".")[0]
      var myNewFolder = new Folder(myPsDoc.path+"/ScriptFolder/");
      if (myNewFolder.exists){
      }else{
          myNewFolder.create();
          }
      newFile = new File(myNewFolder+"/"+justname )
      photoshopSaveOptions = new PhotoshopSaveOptions()
      photoshopSaveOptions.embedColorProfile = false
      myPsDoc.saveAs(newFile, PhotoshopSaveOptions, true,Extension.LOWERCASE)

        • 1. Re: CS3 folders with spaces in the name
          Michael L Hale Community Member

          Using decodeURI should take care of the problem with spaces in the path.

           

          var myNewFolder = new Folder( decodeURI(myPsDoc.path) +"/ScriptFolder/");

          • 2. Re: CS3 folders with spaces in the name
            John.Kordas Community Member

            Thanks Michael but I'm still getting the same error on decodeURI(myPsDoc.path).

             

            Did a little test using:

             

            changed var myNewFolder = new Folder(decodeURI(myPsDoc.path)+"/ScriptFolder/");

             

            to var myNewFolder = new Folder("/c/Hold/Resize test folder/ScriptFolder");

             

            still got the error.

             

             

             

            changed newFile = new File(myNewFolder+"/"+justname)

             

            to newFile = new File("/c/Hold/Resize test folder/ScriptFolder"+"/"+justname)

             

            and the script worked.

             

            so then I tried newFile = new File(decodeURI(myNewFolder)+"/"+justname)

             

            Thanks for you help much appreciated.

             

            Cheers John.