Deleting file in Execute console



  • Answer, please, if there is any npp-console command (such as npp-save) for deleting file. I need to delete old executable file before compilation on g++. Maybe you know another way to prevent running of the old exe-file if compilation is failed. Example:
    PP_SAVE: C:\Qt\MinGW\projects\02\test3.c
    CD: C:\Qt\MinGW\projects\02
    Current directory: C:\Qt\MinGW\projects\02
    g++ “test3.c” -o test3 -march=native -O3 -std=c++11
    Process started >>>
    test3.c: In function ‘int main()’:
    test3.c:54:23: error: ‘vu33’ was not declared in this scope
    for (; c3_Iter != vu33.end(); c3_Iter++)
    **<<< Process finished. (Exit code 1)
    NPP_RUN: test3 **



  • @Александр-Шапошников

    use the standard cmd shell del command.

    Cheers
    Claudia



  • Thanks, Claudia.
    But:
    Result of adding command " del $(NAME_PART).exe" in Execute script:

    NPP_SAVE: C:\Qt\MinGW\projects\02\test3.c
    CD:
    Current directory: C:\Qt\MinGW\projects\02
    del test3.exe
    CreateProcess() failed with error code 2:
    the specified file was not found

    Result of adding command “NPP_RUN del test.exe”
    NPP_RUN: del test.exe

    • the specified file was not found


  • @Александр-Шапошников

    you need to call it from within the cmd shell.
    See NppExec notes

    4.4. Using cmd.exe

    NppExec by itself does not support standard console commands such as “copy”, “move”, “mkdir”, “for” etc. Actually, these commands are part of system’s command interpreter (cmd.exe). So, you can use cmd.exe to perform such commands. For example, you can type the following commands in NppExec’s Console or inside NppExec’s script:

    // create a directory C:\Backup
    cmd /c mkdir C:\Backup
    // save current Notepad++'es file
    NPP_SAVE
    // copy current file to C:\Backup
    cmd /c copy "$(FULL_CURRENT_PATH)" "C:\Backup\$(FILE_NAME)" /Y 
    // change current directory
    cd C:\Backup
    // list all .txt files in C:\Backup
    cmd /c for %f in (*.txt) do @echo %f
    

    If you want to see what happens within the cmd shell, replace /C with /K
    and console will stay open.

    Cheers
    Claudia



  • @Claudia-Frank

    It works!

    Thank you!


Log in to reply