How can I search and delete a file, and a directory in a Wise Script without knowing the path to where the file or directory exists?

Wise has the built in Option Delete File, or Delete File/Dir, but that option needs the path like %SYSDRIVE%\Myfile.txt or %SYSDRIVE%\MyDir\*.*

I want to search for a file on my hard drives and if they exist delete them. Same for Directories.

I am new ot WISE any help is greatly appreciated.
0 Comments   [ - ] Hide Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity


There's a search for file command in wise script that will work. Either Search or Find, I don't remember which and my new job doesn't use wise so I can't double check it.

EDIT: Found it. Find File in Path. You can search the entire drive, or limit it to certain directories to speed it up. Note that the command only returns the first file it finds.
Answered 03/04/2005 by: Bladerun
Green Belt

Please log in to comment
Thanks. Options for searching and deleting files is built into Wise and you can search for directory if you know the pathname, but
Wise is just wierd for searching for Directories without a pathname.

There could be other methods but I used this to search for my directory. I hope it helps someone.

Eg. If you are looking for a DIR Called Msoffice which is not installed in the root but is in C:\TEMP\ directory, it becomes tough to search for that directory, if you do not know where is it installed and you need to search for that directory.

Solution - Instead of searching for the Dir, you search for a file that you know would be in that Dir.
1) So you first search for Word.exe and get the pathname into a variable
/Use built in Search for File Option
2) Now, If the above Pathname Variable is not ""
/Which would mean that WISE found a path to that File
3) Parse the above Pathname Variable for the Directory name that you are searching and make it stop at the first occurence of that directory name
/Use the built in Parse String Option
4) Parse the above into another variable
This new variable is the path to your search directory

I hope it helps.
Answered 03/04/2005 by: aek
Purple Belt

Please log in to comment