Deleting a file from local filesystem

I am just starting of my journey into Photoshop new API and UXP

I have a current script in extendscript that i am translating to UXP. However i can’t work out how to delete files from local storage could someone help me translate this piece of my code

var f = new File(sDoc.path + "/" + sDoc.name);
var m = new File(mDoc.path + "/" + mDoc.name);
var fSize = Math.round(100*f.length/1024)/100000; 
  m.remove();
f.remove();    

Hi @gibsoneditions ,

Welcome to the Adobe Creative Cloud Developer Forums! If you mean accessing files that are stored locally, here are the related UXP API references for file access. This document recommends storage options for UXP development.

With UXP, files and folders can exist in the plugin folder and the temporary plugin-specific (“plugin data folder”) storage. UXP can’t access any other files on the host system without showing a file-picker dialog to the user. Call getDataFolder() and that “plugin data folder” exists for your persistent storage operations.
https://developer.adobe.com/photoshop/uxp/2022/uxp/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/

Hope this helps!

Best,
Amanda Huang

Many Thanks for this, thats very useful info.

My script is to combine to prexisting PSD files and discard one of them, so the automation and access to the filesystem was super useful in extendscript, but i understand its a sandboxing requirement, ill have a go with this new file picker option,

many thanks

1 Like