Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Button handy
blanktrue
color#0052CC
nameSend Feedback
linkhttps://docs.google.com/forms/d/e/1FAIpQLScmToBe3vynAlb5fdKwCGxYqnTbDc66sIBgeecG2BuFDuHc7g/viewform?entry.2002826954=Remove+a+SIL+directory+-+1222738318
widthauto

Excerpt

Remove a directory and recursively delete the files within.

...

Code Block
/**
* Deletes a directory within silprograms and all the containing files.
* @author Tim Reiking
* @date   2020/4/10
*/

string dirName = ""; // Name of the directory

// Determine if the directory contains the silprograms path
if(!startsWith(dirName, silEnv("sil.home"))) { dirName = silEnv("sil.home")+"/"+dirName; }

// Deletes the directory recursively
if(directoryExists(dirName)) { 
    runnerLog("Deleting... "+dirName);
    if(system("rm -R "+dirName)[0] == "-1.0") {
      system("powershell -command \"Remove-Item '"+dirName+"' -Recurse -Force\"");
    }
} else {
    runnerLog("Cannot find "+dirName);
}
We've encountered an issue exporting this macro. Please try exporting this page again later.