Skip to main content
AG_Ps_100
Inspiring
Dec 28, 2019 7:42 PM UTC
Answered

Delete Active Document - Recycle Bin

Hello everyone,

 

I'm running windows 10 and I have this small script to delete active document. This script is irreversible the file is being deleted for good. Is there a way to upgrade the script to send it to the recycle bin ?

 

Here is my code:

#target photoshop


var FullPath = app.activeDocument.path.fsName;
var Name = app.activeDocument.name;  

var myFile = new File(FullPath + "\\"  + Name);

myFile.remove();

 

This topic is closed to new replies. Start a new post to keep the conversation going.
r-binCorrect answer
Legend
Dec 28, 2019 11:30 PM UTC
Give it a try.
Works. Checked on win7.

 

var FullPath = app.activeDocument.path.fsName;
var Name = app.activeDocument.name;  

var p = (FullPath + "\\"  + Name).toSource();
p = p.replace(/^\(new String\(/, "");
p = p.replace(/\)\)$/, "");
var js = new File(Folder.temp.fsName + "/tmp.js");
js.open("w");
js.encoding = "UTF8";
js.writeln('(new ActiveXObject("shell.application")).NameSpace(10).MoveHere(' + p + ');');
js.close();
js.execute();

 

 

 

4 replies

r-binCorrect answer
Legend
Dec 28, 2019 11:30 PM UTC
Give it a try.
Works. Checked on win7.

 

var FullPath = app.activeDocument.path.fsName;
var Name = app.activeDocument.name;  

var p = (FullPath + "\\"  + Name).toSource();
p = p.replace(/^\(new String\(/, "");
p = p.replace(/\)\)$/, "");
var js = new File(Folder.temp.fsName + "/tmp.js");
js.open("w");
js.encoding = "UTF8";
js.writeln('(new ActiveXObject("shell.application")).NameSpace(10).MoveHere(' + p + ');');
js.close();
js.execute();

 

 

 

Translate
AG_Ps_100
AG_Ps_100Author
Inspiring
Jan 19, 2020 2:45 PM UTC

once again @r-bin, thank you. it wokred.

Translate
Kukurykus
Legend
Dec 28, 2019 8:29 PM UTC

'It deletes the file associated with this object from disk, immediately, without moving it to the system
trash. It cannot be undone. It is recommended that you prompt the user for permission before deleting.'

 

The above is taken from 'JAVASCRIPT TOOLS GUIDE'. I suggest to try with system()

Translate