How do I delete a file?

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

clamoreaux

How do I delete a file?

Post by clamoreaux »

I am trying to delete a file (CS5), if it exists, but I am getting an error saying "txtFile is undefined". The file does exists, but what am I doing wrong? The curDoc variables are all defined and I know it creates txtFile fine because I can write to it later. I just need to delete it if it exists.:

Code: Select all        var fileName = curDoc.path+"/" + curFName + ".txt";
        var txtFile = new File(fileName);

        if(txtFile.exists)
            txfFile.remove();

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

kpt

How do I delete a file?

Post by kpt »

It says "txfFile" on the last line, probably a spelling error?
Mike Hale

How do I delete a file?

Post by Mike Hale »

I don't see anything wrong with the code you posted. And if I define curDoc and curFName it runs for me without errors.

Variables are case sensitive. You may want to check that it is not referneced as txtFIle( a common mistake for me ) or something similar in your full code.