Page 1 of 1

Want to handle the error while deleting some files and folders

Posted: 09 Feb 2018 07:06
by naraen87
I want to handle the error if anything went wrong while deleting the files and folders.
My target files and folders are on remote server not on the same server..
I tried with pushd, popd and rd commands but unfortunately it doesn't sends the errorlevel
Can anyone help me on this..

MY Requirement with following conditions

1. Delete all the files and folders expect the parent folder (log) on a remote server for example my remote server path

"Adminlogpathtofolder=\\%servername%\e$\Oracle\Middleware\user_projects\domains\Skandia\servers\AdminServer\logs\"

2. Delete all files and folders with some exclusion say for example this is the following path

"Adminpathtofolder=\\%servername%\e$\Oracle\Middleware\user_projects\domains\Skandia\servers\AdminServer\"

I want to delete all the files and folders except some three folders and its content (logs, security, stage)

3. I want to handle the error if something went wrong while deleting the files or folder the script needs to come out and echo the error which I got in cmd.