?
Solved

unix script to dos script

Posted on 2004-03-30
3
Medium Priority
?
315 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
NVRAM earned 1000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

743 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