2 Replies Latest reply on Aug 17, 2016 7:00 PM by squirpy

    copy file to trash

    squirpy Level 1

      I have temporarily been using the overly destructive method (.remove) to automatically delete files that I am one working with. However I would like to copy them to the trash THEN remove them.  Here's what I put together, but it's not doing the copying, instead returning the result false:


      var original = new File (app.activeDocument.path+"/"+app.activeDocument.name); 
      var trash = new Folder ("~/.Trash");
      new File(original).remove();
        • 1. Re: copy file to trash
          pixxxel schubser MVP & Adobe Community Professional

          Hi squirpy,

          var trash = new Folder ("~/.Trash");

          Where the syntax comes from?

          Which OS do you use?


          I wonder:

          "Folder.trash" is without a dot. Under Windows Folder.trash is a virtuell database, is readonly and the result is always null.



          • 2. Re: copy file to trash
            squirpy Level 1

            Sorry, I guess I left out some relevant information...


            I am using OS X. I know that that is the path to the trash in the Unix shell. The '~' represents my home folder and the '.' indicates that the folder is hidden.  If I hop into terminal and type 'cd ~/.Trash' it takes me to my trash folder.


            I am NOT positive that I can utilize the above path to my trash in javascript executed by photoshop, but have always had luck using these Unix paths to open files, etc.