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

Delete Active Document - Recycle Bin

Engaged ,
Dec 28, 2019 Dec 28, 2019

Copy link to clipboard

Copied

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

Views

1.2K

Translate

Translate

Report

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

 

 

 

Votes

Translate

Translate
Adobe
LEGEND ,
Dec 28, 2019 Dec 28, 2019

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

 

 

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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('\\\\') + '");'

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

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