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

Delete Folder using CEP extension InDesign

Community Beginner ,
Sep 22, 2022 Sep 22, 2022

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?

TOPICS
How to , Scripting
265
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

Community Expert , Sep 22, 2022 Sep 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.

Translate
Community Expert ,
Sep 22, 2022 Sep 22, 2022
LATEST

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
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