Solved

unix script to dos script

Posted on 2004-03-30
3
309 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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 video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now