Skip to main content
Participant
September 22, 2022
Answered

Delete Folder using CEP extension InDesign

  • September 22, 2022
  • 1 reply
  • 250 views

I want to delete a temporary folder which I created in AppData Roaming. 

Is there any API whch helps in doing that using CEP extension for InDesign?

This topic has been closed for replies.
Correct answer Charu Rajput

Hi @devs27984525 

You can use node module fs to delete the file. Below is the simple code that you try

 

var fs = cep_node.require('fs');
if (fs.existsSync(path)) {
    var file = path + fileName;
    fs.unlink(file, (err) => {
        if (err) {
            console.error(err)
            return;
        }
    })
} else {
    console.log(path + ' does not exists. So file is not deleted.')
}

 

 

Where path varaibale is the path where file exists and fileName= actualName of the file.

1 reply

Charu Rajput
Community Expert
Charu RajputCommunity ExpertCorrect answer
Community Expert
September 22, 2022

Hi @devs27984525 

You can use node module fs to delete the file. Below is the simple code that you try

 

var fs = cep_node.require('fs');
if (fs.existsSync(path)) {
    var file = path + fileName;
    fs.unlink(file, (err) => {
        if (err) {
            console.error(err)
            return;
        }
    })
} else {
    console.log(path + ' does not exists. So file is not deleted.')
}

 

 

Where path varaibale is the path where file exists and fileName= actualName of the file.

Best regards