1.

Solve : Removing a directory(Folder) if it exists?

Answer»

Hello again, I am trying to remove a folder if it exists and I am getting an error.

The reason I am doing this is beause a user can clean up the folders outside of the application and I don't WANT to know if they have already.

What I have so far is this:

if exists %WORKDIR%\KEN\j1080 rmdir %WORKDIR%\KEN\j1080 /q

Where %WORKDIR% is already defined and tested
Where j1080 is the ACTUAL folder I want to delete and anything below that.

I keep getting the following message:
c:\progra~1\encore\temp\System\KEN\j1080 was unexpected at this time.

Ken
if EXIST %WORKDIR%\KEN\j1080 (rmdir %WORKDIR%\KEN\j1080 /q)

how does this work?
(no S at the end of exist and the do-if-true expression in parenthesis)Better, but got this message..

The directory is not empty.try the /s flag as well
/s   : Removes the specified directory and all subdirectories INCLUDING any FILES.

Code: [Select]if exist %WORKDIR%\KEN\j1080 (rmdir %WORKDIR%\KEN\j1080 /s /q)that worked, thanks



Discussion

No Comment Found