Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

erase with directory wildcards

Jun
770
6
Doing "erase **\.svn\**\*" causes TCC to disappear (after it asks if I'm sure).

Actually, I wanted to delete all the .svn directories, which I guess the above command wouldn't do (assuming TCC didn't crash). Will /X work with directory wildcards?

TCC 13.00.23 x64 Windows 7 [Version 6.1.7601]
 
Doing "erase **\.svn\**\*" causes TCC to

Not reproducible here.

I can't imagine what you're trying to do that that syntax, but it the result almost certainly wouldn't be what you intended. (Unless you're trying to delete files that are at least two subdirectories down from the .svn directories?)

/X will work with directory wildcards.
 
Is this a confirmed bug?

You're asking for TCC to temporarily save all the info on every file in every directory on your drive, so depending on your system & the amount of files & memory you have, you could easily use up every scrap of RAM you have. (TCC will normally detect an out-of-memory error on its own memory allocations, but if it happens in an RTL function or a Windows API, it usually just crashes the app.)

I cannot think of any reason to have two directory wildcards in a wildcard spec (and you have three!).
 
I can't imagine what you're trying to do that that syntax,

I was trying to delete all directories named .svn, many of which contained files or directories. Is there a syntax that will do that?

Someone sent me a zip of their development folder. It had all these .svn directories at various levels down. I don't need them. So, I wanted to delete them. I ended up doing it in Epsilon (the text editor I use). It was pretty easy to do in Epsilon: A dired on **\.svn listed 237 directories. Holding down the "D" key marked them all for deletion. Pressing "X" told Epsilon to delete them. It asked me to confirm that I should delete them even though they weren't empty. Then it did it.

You're asking for TCC to temporarily save all the info on every file in every directory on your drive

Am I? I thought it would just walk through the folder/file tree deleting things as it goes. (I actually ran the command from a sudirectory, not from c:\.)
 
Am I? I thought it would just walk through the folder/file tree deleting things as it goes.

No, you told TCC to look in every subdirectory and all of their subdirectories for a directory named .svn. But TCC had to save every parent directory so it could back up and go down the next subdirectory tree.

Then, you told TCC that once it found a .svn directory, look in every one of its subdirectories for another subdirectory, and delete the files in that sub-subdirectory. (And TCC had to save each parent directory again.)
 
I was trying to delete all directories named .svn, many of which contained files or directories. Is there a syntax that will do that?

Several, but not with a single DEL statement.

The problem is that first you're trying to delete files in any directory called .svn, which can be done with:

del **\.svn\

But the /X directory removal cannot be done while DEL is recursing into the directory, so it's handled when you've returned from deleting all of the files in all of the matching subdirectories. But then all the directory removal API has to work with is "**\.svn", which isn't going to match anything. So you'll need to do another pass to clean up empty subdirectories.

Or, you could do the same thing as your editor by redirecting DIR output to SELECT, and then deleting the marked directories.
 
The problem is that first you're trying to delete files in any directory called .svn, which can be done with:

del **\.svn\

I'm not following. That doesn't seem to do anything:

HTML:
C:\Junk>ffind /s *
C:\Junk\Sub
C:\Junk\Sub\.svn
C:\Junk\Sub\.svn\foo
C:\Junk\Sub\.svn\bar2.txt
C:\Junk\Sub\.svn\foo\bar.txt

      5 files

C:\Junk>del **\.svn\
TCC: (Sys) The system cannot find the file specified.
 "C:\Junk\Sub\.svn\"
     0 files deleted

C:\Junk>del /e **\.svn\
     0 files deleted

C:\Junk>

Or, you could do the same thing as your editor by redirecting DIR output to SELECT, and then deleting the marked directories.

Do you mean for the second pass or to do the whole thing? I'm not sure what you mean.

The following is odd. Note the doubled backslashes:

HTML:
C:\Junk>ffind /s **\.svn\
C:\Junk\Sub\.svn\\foo
C:\Junk\Sub\.svn\\bar2.txt
C:\Junk\Sub\.svn\\foo\bar.txt

No, you told TCC to look in every subdirectory and all of their subdirectories for a directory named .svn. But TCC had to save every parent directory so it could back up and go down the next subdirectory tree.

Then, you told TCC that once it found a .svn directory, look in every one of its subdirectories for another subdirectory, and delete the files in that sub-subdirectory. (And TCC had to save each parent directory again.)

I don't quite understand the algorithm, but I guess the point is that TCC isn't just checking each file to see if its path matches the spec.
 
I was trying to delete all directories named .svn, many of which contained files or directories. Is there a syntax that will do that?

Code:
global /i if isdir .svn echo del /s /x /z .svn\

Not tested -- handle with care!
 
I don't quite understand the end goal.
But if the desire is to remove all subdirectory trees named .svn,
starting from the current directory, then this should work:

for /a:d /h /r %d in (*) if '%@filename[%d]'
== '.svn' del /sexyz %d

I'd try it with "echo del /sexyz
%d" first to see which directories would be targeted.

-Scott

David Marcus <> wrote on
09/27/2011 06:35:48 PM:


>
> Quote:
>
> Originally Posted by rconn [image removed]
> The problem is that first you're trying to delete
files in any

> directory called .svn, which can be done with:
>
> del **\.svn\
>
> I'm not following. That doesn't seem to do anything:


> HTML Code:
> C:\Junk>ffind /s *
> C:\Junk\Sub
> C:\Junk\Sub\.svn
> C:\Junk\Sub\.svn\foo
> C:\Junk\Sub\.svn\bar2.txt
> C:\Junk\Sub\.svn\foo\bar.txt
>
> 5 files
>
> C:\Junk>del **\.svn\
> TCC: (Sys) The system cannot find the file specified.
> "C:\Junk\Sub\.svn\"
> 0 files deleted
>
> C:\Junk>del /e **\.svn\
> 0 files deleted
>
> C:\Junk>
> Quote:
>
> Or, you could do the same thing as your editor by redirecting DIR


> output to SELECT, and then deleting the marked directories.
>
> Do you mean for the second pass or to do the whole thing? I'm not


> sure what you mean.
>
> The following is odd. Note the doubled backslashes:


> HTML Code:
> C:\Junk>ffind /s **\.svn\
> C:\Junk\Sub\.svn\\foo
> C:\Junk\Sub\.svn\\bar2.txt
> C:\Junk\Sub\.svn\\foo\bar.txt
> Quote:
>
> No, you told TCC to look in every subdirectory and all of their
> subdirectories for a directory named .svn. But TCC had to save every
> parent directory so it could back up and go down the next subdirectory
tree.

>
> Then, you told TCC that once it found a .svn directory, look in
> every one of its subdirectories for another subdirectory, and delete
> the files in that sub-subdirectory. (And TCC had to save each parent
> directory again.)
>
> I don't quite understand the algorithm, but I guess the point is
> that TCC isn't just checking each file to see if its path matches
the spec.
 
If you wanted to start in a different directory
than the current one you could do this:

alias delsvn=`for /a:d /h /r %1 %d in
(*) if %@filename[%d] == .svn echo del /sexyz %d`

delsvn
delsvn c:\foo\bar
etc.

-Scott


samintz <> wrote on 09/27/2011
08:08:37 PM:


> I don't quite understand the end goal.
> But if the desire is to remove all subdirectory trees named .svn,
> starting from the current directory, then this should work:
>
> for /a:d /h /r %d in (*) if '%@filename[%d]'
> == '.svn' del /sexyz %d
>
> I'd try it with "echo del /sexyz
> %d" first to see which directories would be targeted.
>
> -Scott
>
>
 
Or alternatively, you could use DO instead
of FOR:

do d in /d"c:\foo\bar" /s
/a:d * (if %d == .svn echo del /sexyz %@full[%d])

-Scott

samintz <> wrote on 09/27/2011
08:18:11 PM:


> If you wanted to start in a different directory
> than the current one you could do this:
>
> alias delsvn=`for /a:d /h /r %1 %d in
> (*) if %@filename[%d] == .svn echo del /sexyz %d`
>
> delsvn
> delsvn c:\foo\bar
> etc.
>
> -Scott
>
>
> samintz <> wrote on 09/27/2011
> 08:08:37 PM:
>


> Quote:
>
> > I don't quite understand the end goal.
> > But if the desire is to remove all subdirectory trees named .svn,
> > starting from the current directory, then this should work:
> >
> > for /a:d /h /r %d in (*) if '%@filename[%d]'
> > == '.svn' del /sexyz %d
> >
> > I'd try it with "echo del /sexyz
> > %d" first to see which directories would be targeted.
> >
> > -Scott
> >
> >
>
>
>
 
If you wanted to start in a different directory
than the current one you could do this:

alias delsvn=`for /a:d /h /r %1 %d in
(*) if %@filename[%d] == .svn echo del /sexyz %d`

delsvn
delsvn c:\foo\bar
etc.

Or maybe even:

alias delsvn=`for /a:d /h /r %1 %d in ( .svn[] ) echo del /s /e /x /y /z %d`
 
From: Charles Dye
| alias delsvn=`for /a:d /h /r %1 %d in ( .svn[] ) echo del /s /e /x /y /z %d`

I'd modify this a little more to take care of names with embeddes spaces, etc. (%1 is already guaranteed to be quoted if needed):

alias delsvn=`for /a:d /h /r %1 %d in ( .svn[] ) echo del /s /e /x /y /z %@quote[%d]`
--
Steve
 
I'd modify this a little more to take care of names with embeddes spaces, etc. (%1 is already guaranteed to be quoted if needed):

alias delsvn=`for /a:d /h /r %1 %d in ( .svn[] ) echo del /s /e /x /y /z %@quote[%d]`

I'd like to mention that while this is all very interesting, I did realize that I could come up with something involving FOR or GLOBAL to do what I wanted. But, since this was a one-time need, when a simple erase didn't work, it took me much less time to do it using Epsilon's dired than it would have taken me to be sure I had a correct TCC solution.

Using "rmdir /s **\.svn" might also work, but I'd have to test it first.

With Epsilon, it was obvious what Epsilon was about to delete, so no testing was needed.
 
You're right; the paths returned might contain spaces. Is there some advantage to using @QUOTE, as opposed to just putting quotes around the %d ?
 
From: Charles Dye
| Is there some
| advantage to using @QUOTE, as opposed to just putting quotes around
| the %d ?

In this instance - no. It's better coding practice in general because the value of the variable may already be quoted.

Of course, it would be nice if FOR and DO could be enhanced by an option to quote names requiring it; PDIR already has that feature, both for the "*" being used to pass the current filespec to a function, and the "q" suboption of the "f" reporting field. Likewise, all filename-valued internal variables and variable functions ought to have "autoquoting" variants.
--
Steve
 

Similar threads

Back
Top