[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 9419
  • Last Modified:

Delete directory and all subdirectory method

Is there any command for deleting a directory and all subdirectories and/or files?

Or does anyone have a good script (*.cmd) file for doing this?
0
Axter
Asked:
Axter
  • 8
  • 5
  • 4
  • +1
2 Solutions
 
LowfatspreadCommented:
can't remember if you can doit...
but I think the Rexx tutorials used to include a sample code to do something like this.....

0
 
AxterAuthor Commented:
>>but I think the Rexx tutorials used to include a sample code to do something like this.....

I have no idea of what that is.
0
 
LowfatspreadCommented:
Rexx  is lnguage for basically writting command procedures , available on most IBM Operating systems...
I had a quicl look around but couldn't find what i wanted...
I'll try and look further.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
itsmeandnobodyelseCommented:
Check for deltree command.

the syntax is

  deltree <path> /y /f

/y answers all questions with 'yes'
/f forces deltree to delete all files and sub directories

Regards, Alex
0
 
Danny KonCommented:
From site rob van der woude you can copy past this rexx util
Good luck
Dan


PARSE UPPER ARG user_dir confirm

IF STRIP(user_dir,'B') = '' THEN
      DO
             SAY 'You must enter a directory name to erase.'
             SAY 'To erase the current directory and all the ones below'
           SAY 'it, use a period (.).'
             EXIT 3
      END

/***********************************************************************/
/* Load the OS/2 RexxUtil DLL and make some functions available        */
/***********************************************************************/

CALL RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
CALL RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
CALL RxFuncAdd 'SysRmDir', 'RexxUtil', 'SysRmDir'

/***********************************************************************/
/* Load text strings for SysFileDel and SysRmDir return codes.         */
/***********************************************************************/

CALL LoadDELRCText   /* provides text strings for SysFileDel return codes */
CALL LoadRDRCText    /* provides text strings for SysRmDir return codes   */

/**************************************************************************/
/*Check to make sure the directory exists - if it does prompt the user to */
/*make sure they really want to do this.   Otherwise issue a message and  */
/*exit                                                            */
/**************************************************************************/

rc=SysFileTree(user_dir,dir_list, 'D')
IF dir_list.0 = 0  THEN
        DO
             SAY user_dir 'not found, try again.'
             EXIT 1
        END

DROP dir_list.

/***********************************************************/
/* Make sure the user really wants to do this              */
/***********************************************************/

IF confirm \= "/Y" THEN DO
      SAY 'Are you sure? (Y/N)'
      PULL answer .
      IF LEFT(answer,1,1) <> 'Y' THEN EXIT 1
END

/***********************************************************/
/* Mark all the read-only files to be non read-only        */
/***********************************************************/

rc=SysFileTree(user_dir, dir_list, 'BO', '****','----')

DROP dir_list.

/***********************************************************/
/* Go through the list of files and delete each one        */
/***********************************************************/

rc=SysFileTree(user_dir || '\*.*', dir_list, 'FSO')
DO x = 1 TO dir_list.0
      rc = SysFileDelete(dir_list.x)
      SAY dir_list.x '........' DELRCText.RC
END

DROP dir_list.

/*************************************************************/
/* Go through all the subdirectories and remove them.        */
/* We go backwards through the list in order to delete the   */
/* lowest level sudirectories first and work our way back up */
/* the tree.                                                 */
/*************************************************************/

rc=SysFileTree(user_dir || '\*.*', dir_list, 'DSO')
DO x = dir_list.0 TO 1 BY -1
      rc=SysRmDir(dir_list.x)
      SAY dir_list.x '........' RDRCText.RC
END

DROP dir_list.

/**************************************************************/
/* Delete the directory the user passed                    */
/**************************************************************/

rc=SysRmDir(user_dir)
SAY user_dir '........' RDRCText.RC

EXIT 0


/**************************************/
/* Local subroutines                  */
/**************************************/

LoadDELRCText:
      /* provides text strings for SysFileDel return codes */
      /* The return codes and strings are in the online Rexx manual */

      DELRCText.0 = 'File deleted successfully. '
      DELRCText.2 = 'Error.  File not found. '
      DELRCText.3 = 'Error.  Path not found. '
      DELRCText.5 = 'Error.  Access denied. '
      DELRCText.26 = 'Error.  Not DOS disk. '
      DELRCText.32 = 'Error.  Sharing violation. '
      DELRCText.36 = 'Error.  Sharing buffer exceeded. '
      DELRCText.87 = 'Error.  Invalid parameter. '
      DELRCText.206 = 'Error.  Filename exceeds range error. '
RETURN

LoadRDRCText:
      /* provides text strings for SysRmDir return codes */
      /* The return codes and strings are in the online Rexx manual */

      RDRCText.0 = 'Directory removal was successful. '
      RDRCText.2 = 'Error.  File not found. '
      RDRCText.3 = 'Error.  Path not found. '
      RDRCText.5 = 'Error.  Access denied. '
      RDRCText.16 = 'Error.  Current Directory. '
      RDRCText.26 = 'Error.  Not DOS disk. '
      RDRCText.87 = 'Error.  Invalid parameter. '
      RDRCText.108 = 'Error.  Drive locked. '
      RDRCText.206 = 'Error.  Filename exceeds range error. '
RETURN
0
 
AxterAuthor Commented:
itsmeandnobodyelse,

There is no deltree function.
At least not on my OS2 box.
0
 
AxterAuthor Commented:
dannykon,

Sorry dannykon, but I don't even know how I would use the above code, and I'm really interested in a method that would use *.CMD file or built-in OS function.
0
 
Danny KonCommented:
Axter,

Open an editor and copy past the above code, save the file as thenameyouwant.cmd

Good-Luck

Dan
0
 
Danny KonCommented:
Axter,

Before i forget

above the first line of code "PARSE UPPER ARG user_dir confirm" There have to be an indication for os/2 that this is a rexx file

So start the file with    /*   */  
after this you can paste the rest of the above code

/*   */  
PARSE UPPER ARG user_dir confirm

IF STRIP(user_dir,'B') = '' THEN
     DO

Etc etc etc

Good-Luck

Dan



0
 
itsmeandnobodyelseCommented:
I could send you a deltree.exe for OS/2 (11k 1994). Is  info ad axter dot com a valid  e mail address?

Regards, Alex

BTW, there is also a deltree.exe for Windows as

          del /s

doesn't work on W9x systems (as far i know).
0
 
AxterAuthor Commented:
>>I could send you a deltree.exe for OS/2 (11k 1994). Is  info ad axter dot com a valid  e mail address?

No.

I'm not sure if you can view the feedback, but I posted a valid email address in the feedback message.
0
 
itsmeandnobodyelseCommented:
Finally, i found my feedback view ;-)

Did you get my mail?

Try deltree /? first. That is save. I tested it.

Regards, Alex
0
 
AxterAuthor Commented:
>>Did you get my mail?

Yes.   I'll try it out tomorrow when I get to work.

Did you get an email notificatiion when I posted the feedback?
0
 
itsmeandnobodyelseCommented:
> Did you get an email notificatiion when I posted the feedback?

No, it's the first time i even recognized that possibility. I wonder if there is any kind of notification when receiving a feedback?

0
 
Danny KonCommented:
Axter

Download the deltree command at location http://www.robvanderwoude.com/files/deldir.zip

Dan

0
 
AxterAuthor Commented:
>>No, it's the first time i even recognized that possibility. I wonder if there is any kind of
>>notification when receiving a feedback?

How were you able to view your feedback?

Now I'm woundering if I've ever got a feedback.
0
 
itsmeandnobodyelseCommented:
How were you able to view your feedback?

In "My Account" is a member feedback view...

You have 2 positive old feedbacks - same as me....

Regards, Alex
0
 
AxterAuthor Commented:
I just figured out how to view my feedback.
I only had 2, so I guess this feature doesn't get used too much.
0
 
AxterAuthor Commented:
Thank you both for your help.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 8
  • 5
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now