Page 1 of 1 1
Topic Options
#149142 - 2005-10-04 01:05 AM DEL Command
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
I am using the DEL command in a script like this: Code:
 IF @UserID = Techwall OR Wordp OR Homework
DEL 'c:\tempdrive\*' /h /s
ENDIF


The C:\tempdrive directory needs to be emptied of all files and folders upon logoff. The way I'm using DEL in the script above only deletes the files from the root directory and sub directories.

Is there a way to also delete the folders ?

Thanks again!
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#149143 - 2005-10-04 01:08 AM Re: DEL Command
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Your IF conditional is wrong.

You can shell out to use DOS.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#149144 - 2005-10-04 01:16 AM Re: DEL Command
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
I've tried using the DOS DEL command as well, but it too doesn't delete the folders, only files of the root directory and subdirectories.


I have also tried the DOS Del command, with the same results.
DOS DEL SYNTAX: Code:
 del c:\tempdrive\* /s /q 



Am I missing something?
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#149145 - 2005-10-04 01:53 AM Re: DEL Command
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
not really.
use deltree to get rid of all of it.
_________________________
!

download KiXnet

Top
#149146 - 2005-10-04 02:04 AM Re: DEL Command
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
Thanks for the reference Jooel. I haven't used deltree for years. Even though deltree isn't part of Win2000 or XP, after searching the Internet for info on DELTREE, I was able to find a reference for a Win2000/XP equivelant called RMDIR.

By any chance, does/will KiXtart have a similar command?
*Edit, answered my own question.
Quote:

RD
Action
Removes the directory specified. Note: the directory must be empty for this command to succeed.

Syntax
RD "directory"

Remarks
Check the value of @ERROR to see if RD was successful.





Edited by StarwarsKid (2005-10-04 02:08 AM)
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#149147 - 2005-10-04 02:13 AM Re: DEL Command
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, actually, for win2k and onwards I think RD is capable of doing what deltree did back in DoS days.
can't remember what was the state for RD in NT4 though.

also, yes, kixtart RD should be enhanced to work similarly.
if it will and when is another question.
_________________________
!

download KiXnet

Top
#149148 - 2005-10-04 02:17 AM Re: DEL Command
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
It looks like you have to explicitly specify the directory name in the KiXtart RD command or it won't delete the subdirectories. In that case, I will probably SHELL the DOS RD command instead.
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#149149 - 2005-10-04 02:21 AM Re: DEL Command
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ja, exactly what I ment in my post.
kixtart's RD has no /S switch.

also command prompt RD does delete also files with that switch, thus it perfect replacement for deltree.
_________________________
!

download KiXnet

Top
#149150 - 2005-10-04 02:24 AM Re: DEL Command
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
SHELL to RD /S /Q

KiXtart has RD but doesn't work with files in it and DEL does not remove the directories. There is request to Ruud update so that it works like RD from OS.

Top
#149151 - 2005-10-04 02:31 AM Re: DEL Command
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
One observation from my work today:

I want to delete the contents of a directory, but not the directory itself. Since the contents of the directory will be random and unspecifyable, I would have to use the DOS RD command like this: Code:
 SHELL "CMD.EXE /C RD c:\tempdrive\ /s /q" 



That not only deletes the contents of c:\tempdrive\ but also c:\tempdrive\ itself, which is something I'm trying to avoid. There's always a work-around if I can't avoid it, but, (*ugh*)...

Thanks for all the input. I will keep my eyes opened for this future improvement of KiXtart.
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#149152 - 2005-10-04 02:37 AM Re: DEL Command
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Jens wrote a UDF that will clean any folder and he claims it does subfolders.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#149153 - 2005-10-04 02:39 AM Re: DEL Command
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
cd to TEMPDRIVE and issue the RD command. It can't remove a folder that is active.
Top
#149154 - 2005-10-04 06:12 AM Re: DEL Command
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See CleanDirectory() - Cleans up the temporary directories ( or any arbitrary directory) and Not quite everything you wanted to know about RUN and SHELL and never hard-code CMD.EXE
_________________________
There are two types of vessels, submarines and targets.

Top
#149155 - 2005-10-04 06:00 PM Re: DEL Command
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
To clarify: Should I then use the env variable, %comspec% /c, instead of explicitly calling cmd.com?

NTDOC, It appears that I can't delete subdirectories with your CD suggestion due to a share violation.

Code:
 debug on
IF @UserID = Techwall OR Wordp OR Homework
DEL 'c:\tempdrive\*' /h /s
CD c:\tempdrive\
SHELL "%comspec% /C RD c:\tempdrive\"
ENDIF
EXIT


Quote:

The process cannot access the file because it is being used by another process.





SeaLeopard: I just implemented your CleanDirectory.UDF and it works great. Thanks for the lead.

FINAL CODE: Code:
 
call "@ScriptDir\UDF\cleandirectory.udf"
call "@ScriptDir\UDF\DateMath.udf"
call "@ScriptDir\UDF\FULLFILE.udf"
IF @UserID = "Techwall" OR @UserID = "Wordp" OR @UserID = "Homework"
DEL 'c:\tempdrive\*' /h /s
$rc=cleandirectory('c:\tempdrive','*')
ENDIF
EXIT



Edited by StarwarsKid (2005-10-04 07:12 PM)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 476 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.069 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org