Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Delete Active Document - Recycle Bin

Engaged ,
Dec 28, 2019 Dec 28, 2019

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();

 

TOPICS
Actions and scripting , Windows
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Dec 28, 2019 Dec 28, 2019
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
Adobe
LEGEND ,
Dec 28, 2019 Dec 28, 2019

'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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 28, 2019 Dec 28, 2019
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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 28, 2019 Dec 28, 2019

You may also instead of first 5(6) lines use this code:

 

 

 

'"' + activeDocument.fullName.fsName.split('\\').join('\\\\') + '"' 

 

 

 

or directly instead of p variable, just with double quotation marks:

 

 

cde = '(new ActiveXObject("shell.application")).NameSpace(10).MoveHere'
cde += '("' + activeDocument.fullName.fsName.split('\\').join('\\\\') + '");'

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 19, 2020 Jan 19, 2020
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines