erase with directory wildcards

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]
 

rconn

Administrator
Staff member
May 14, 2008
12,365
150
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.
 

rconn

Administrator
Staff member
May 14, 2008
12,365
150
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:\.)
 

rconn

Administrator
Staff member
May 14, 2008
12,365
150
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.)
 

rconn

Administrator
Staff member
May 14, 2008
12,365
150
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.
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
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.
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
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
>
>
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
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
> >
> >
>
>
>
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,469
88
Albuquerque, NM
prospero.unm.edu
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`
 
May 20, 2008
3,515
4
Elkridge, MD, USA
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.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
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
Thread starter Title Forum Replies Date
Joe Caverly PAUSE does not erase countdown timer Support 0
C Erase all characters left or right from cursor location Support 2
krischik ERASE crashes TCC Support 10
fishman@panix.com HELP!! I just updated to Version 28 and as usual I cannot make extended directory search work. Support 2
D How to use multi-line DO to loop through first level directory names Support 5
D ParentDirectory does not update directory history Support 6
samintz CDD to non-existent directory hangs Support 2
gworley rd (Remove Directory) gives interesting error: Support 2
D Directory History Window with wildcard search Support 3
D How to? Skip removing directory (RMDIR) without error message Support 2
gentzel Directory stack empty when running TCEXIT? Support 9
vefatica Disable extended directory searches (completely)? Support 8
M WAD "Pictures" directory is empty in TCC but not in CMD or Explorer Support 4
G Local Directory Corruption Support 11
Jay Sage Directory Alias Access to FTP Servers Support 2
Joe Caverly DIRectory Colorization in v25 Help File Support 0
K copy changing destination current directory Support 1
thorntonpg option /u not working The directory name is invalid Support 5
J built in file explorer - how do i go back "up" the directory? Support 2
vefatica Extended directory searches? Support 6
Joe Caverly Using a Directory Alias with @iniwrite fails Support 14
A Installer /extract: extracts into current directory if target not exists Support 12
Charles Dye Ctrl-Shift-Up doesn't update directory history Support 1
G Extended directory search not working Support 4
CWBillow Editing in the root directory of windows 10 Support 6
D Directory stack empty Support 1
J directory or folder to start in Support 2
M How to unlock a directory Support 1
Alpengreis Fixed TCMD FileExplorer Start-Directory problem Support 4
R V19 - At startup, TCC save directory in the directory history list Support 2
C Touch command — I Need to touch matching files in another directory. Support 5
nickles Move takecommand.18.0.key location to installation directory Support 4
fishman@panix.com Extended Directory Searches are not working for me in CDD Support 9
vefatica TCMD's current directory? Support 4
J How to set working directory Support 10
nickles How to? Follow a JUNCTION type directory link Support 9
Steve Pitts WAD Strange output from DEL of a non-existent directory Support 7
I tab completion with directory commands Support 7
vefatica Start-up directory for new tabs? Support 7
cgunhouse Problem with CALL and Directory Aliases in V17 Support 9
vefatica FFIND /S, find directory with specified name? Support 7
David Wilbanks How to make new tab open in same directory as previous tab? Support 4
H WAD Wild Card in Directory @shfolder[25] acting differently Support 3
M How to? List path getting short file and directory names... Support 10
A How to? Can't change directory ("cd") into system hidden files Support 13
mfarah How to? So I want a custom directory for the plugins... Support 16
D Why doesn't ffind find directory? Support 3
T dir /h error in empty directory Support 22
S directory history locks up TCC Support 3
B Why Does @GETDIR Repeat Selected Directory Name In Returned Value Support 7

Similar threads