Solved

unix script to dos script

Posted on 2004-03-30
3
312 Views
Last Modified: 2013-12-03
Hi guys,

What would be the equivalent of this unix command from a ksh script in a cmd script in DOS shell?

find . -type d -name blahblah -exec rm {} \;

Thanks!
0
Comment
Question by:vrungel
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
NVRAM earned 250 total points
ID: 10728126
I think there's a typo in what you posted -- the pathnames are directories but you did not add "-r" to the remove.  So either:

1) You meant "-type f" for files rather than directories.  This could be acomplished with:
        del /s/f blahblah
    Add the "/p" flag first to have it prompt you  (and hence not remove any undesired files) to be cautious.

2) You forgot the "-r" after the "rm" and want to remove directories ... hmm. Here:
        dir /s/b/ad blahblah > tempfile.txt
        for /f  %f in (tempfile.txt) do del /s/f/-p %f

     Problem is, I can't seem to remember (if possible) how to make "del" quit prompting.   Grrr.

Anyway, that should be a good start.



0
 

Author Comment

by:vrungel
ID: 10728576
Thanks. My goal was to remove the directory and its contents. So the correct unix command would be

find . -type d -name blahblah -exec rm -Rf {} \;

Now, command dir /s/b/ad blahblah correctly finds directories I need, but I was wondering if it's possible to delete those directories and their contents (rd /s/q) on the fly rather than redirecting them to a list?

By the way, to supress the del confirmation, you need to use /q :)
0
 
LVL 4

Expert Comment

by:NVRAM
ID: 10734454
>Now, command dir /s/b/ad blahblah correctly finds directories I need, but I was wondering if it's possible to delete those
>directories and their contents (rd /s/q) on the fly rather than redirecting them to a list?

Well, you could always install CygWin and the other GNU tools, and use:
   find . -type d -name blahblah -exec rm -rf {} \;
:-)  

But otherwise I don't know of a way without using the file.  Run "help for" (in a DOS shell) and check out the backquoted-command
syntax --it failed to work for me (on MS Windows XP Pro), but I didn't try too hard.  You might have better luck if you want.

>By the way, to supress the del confirmation, you need to use /q :)

I stared right at it (ran "del /?" twice) and still missed it.  Doh.


0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question