Solved

unix script to dos script

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

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…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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 this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

691 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