Windows批处理文件删除。svn文件和文件夹。

时间:2022-04-21 05:23:59

In order to delete all ".svn" files/folders/subfolders in "myfolder" I use this simple line in a batch file:

为了删除所有的。“文件/文件夹/子文件夹”在“myfolder”中,我在批处理文件中使用这个简单的行:

FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X")

This works, but if there are no ".svn" files/folders the batch file shows a warning saying: "The system cannot find the file specified." This warning is very noisy so I was wondering how to make it understand that if it doesn't find any ".svn" files/folders he must skip the RD command.

这是可行的,但如果没有。文件/文件夹的批处理文件显示一个警告:“系统无法找到指定的文件。”这个警告很吵,所以我想知道如果它找不到的话,该如何让它明白。文件/文件夹他必须跳过RD命令。

Usually using wild cards would suffice, but in this case I don't know how to use them, because I don't want to delete files/folders with .svn extension, but I want to delete the files/folders named exactly ".svn", so if I do this:

通常使用通配符就足够了,但是在这种情况下,我不知道如何使用它们,因为我不想用.svn扩展来删除文件/文件夹,但是我想删除指定的文件/文件夹。svn,如果我这样做

FOR /R myfolder %%X IN (*.svn) DO (RD /S /Q "%%X")

it would NOT delete files/folders named exactly ".svn" anymore. I tried also this:

它不会删除指定的文件/文件夹。svn”了。我也试过这样的:

FOR /R myfolder %%X IN (.sv*) DO (RD /S /Q "%%X")

but it doesn't work either, he deletes nothing.

但这也不管用,他什么也没干。

8 个解决方案

#1


41  

you can try

你可以试着

FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X" 2>nul)

#2


4  

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (rd /s /q "%%i")

#3


1  

Something like that using find :

使用find:

rm -rf `find . -name ".svn" -type d`

Edit:

编辑:

I know this is for linux (I read bash instead of batch). I'm leaving it here to help Linux users that would randomly end-up here :)

我知道这是针对linux的(我阅读bash而不是批处理)。我把它放在这里来帮助Linux用户在这里随机地结束:)

#4


1  

Actually, this answer is from Jesper Rønn-Jensen at http://justaddwater.dk/2011/03/01/easy-delete-all-svn-subfolders-in-windows-explorer/

实际上,这个答案是来自于http://justaddwater.dk/2011/03/01/03/01/01/- svn-subfolders-in-windows-explorer/的。

I thought it was so much easier I'd share. I'm converting several projects from .SVN to .GIT, so this was great. It adds a menu item to Explorer so you can remove the folders. Create a .reg file, and import it.

我觉得我能分享的更容易。我正在把几个项目从。svn转换到。git,所以这很好。它向Explorer添加了一个菜单项,这样您就可以删除文件夹了。创建.reg文件并导入它。

Windows批处理文件删除。svn文件和文件夹。

Windows Registry Editor Version 5.00
;
; Running this file will give you an extra context menu item in Windows Explorer
; "Delete SVN folders"
;
; For the selected folder, it will remove all subfolders named ".svn" and their content
; Tip from http://www.iamatechie.com/remove-all-svn-folders-in-windows-xp-vista/
;
; Enrichened with comments by Jesper Rønn-Jensen ( http://justaddwater.dk/ )
;
;
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""

#5


0  

Bizarre sidenote: if I use

奇怪的旁注:如果我使用。

FOR /R . %%X IN (*.svn) DO (echo "%%X")

instead of

而不是


FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X")

not only does it list all directories ending in .svn, it lists ALL THEIR CONTENTS as well. This is a BUG in the For command, it gave me an expansion where I gave it no wild card. Very strange.

它不仅列出了以.svn结尾的所有目录,还列出了它们的所有内容。这是一个命令的错误,它给了我一个扩展,我给它没有通配符。很奇怪。

Ken

#6


0  

If you want to delete all sub folders named .svn in Windows then create batch file with this content:

如果您想要删除所有的子文件夹,请在Windows中选择.svn,然后创建包含该内容的批处理文件:

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *.svn') do (
rd /s /q "%%i"
)

save it in a file del_All_Dot_SVN_Folders.cmd . Run it. Your done.

将它保存在一个文件del_All_Dot_SVN_Folders中。cmd。运行它。你完成了。

Thanks to http://www.axelscript.com/2008/03/11/delete-all-svn-files-in-windows/

由于http://www.axelscript.com/2008/03/11/delete-all-svn-files-in-windows/

Remember the above code has .svn whereas the code in the link has only *svn so its better to have the .svn to not accidentally have undesired effect.

记住上面的代码有。svn,而链接中的代码只有*svn,所以最好有.svn,不要意外地产生不希望的效果。

#7


-1  

Here is my favorite, its simple and compact:

这是我的最爱,它简单紧凑:

find ./ -name ".svn" | xargs rm -Rf

找到。/ - name”。svn" | xargs rm -Rf。

Fissh

Fissh

#8


-2  

To delete all svn files on windows

要删除windows上的所有svn文件。

for /d /r . %d in (.svn) do @if exist "%d" rd /s/q "%d"

.svn is the folder name

.svn是文件夹的名称。

#1


41  

you can try

你可以试着

FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X" 2>nul)

#2


4  

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (rd /s /q "%%i")

#3


1  

Something like that using find :

使用find:

rm -rf `find . -name ".svn" -type d`

Edit:

编辑:

I know this is for linux (I read bash instead of batch). I'm leaving it here to help Linux users that would randomly end-up here :)

我知道这是针对linux的(我阅读bash而不是批处理)。我把它放在这里来帮助Linux用户在这里随机地结束:)

#4


1  

Actually, this answer is from Jesper Rønn-Jensen at http://justaddwater.dk/2011/03/01/easy-delete-all-svn-subfolders-in-windows-explorer/

实际上,这个答案是来自于http://justaddwater.dk/2011/03/01/03/01/01/- svn-subfolders-in-windows-explorer/的。

I thought it was so much easier I'd share. I'm converting several projects from .SVN to .GIT, so this was great. It adds a menu item to Explorer so you can remove the folders. Create a .reg file, and import it.

我觉得我能分享的更容易。我正在把几个项目从。svn转换到。git,所以这很好。它向Explorer添加了一个菜单项,这样您就可以删除文件夹了。创建.reg文件并导入它。

Windows批处理文件删除。svn文件和文件夹。

Windows Registry Editor Version 5.00
;
; Running this file will give you an extra context menu item in Windows Explorer
; "Delete SVN folders"
;
; For the selected folder, it will remove all subfolders named ".svn" and their content
; Tip from http://www.iamatechie.com/remove-all-svn-folders-in-windows-xp-vista/
;
; Enrichened with comments by Jesper Rønn-Jensen ( http://justaddwater.dk/ )
;
;
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""

#5


0  

Bizarre sidenote: if I use

奇怪的旁注:如果我使用。

FOR /R . %%X IN (*.svn) DO (echo "%%X")

instead of

而不是


FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X")

not only does it list all directories ending in .svn, it lists ALL THEIR CONTENTS as well. This is a BUG in the For command, it gave me an expansion where I gave it no wild card. Very strange.

它不仅列出了以.svn结尾的所有目录,还列出了它们的所有内容。这是一个命令的错误,它给了我一个扩展,我给它没有通配符。很奇怪。

Ken

#6


0  

If you want to delete all sub folders named .svn in Windows then create batch file with this content:

如果您想要删除所有的子文件夹,请在Windows中选择.svn,然后创建包含该内容的批处理文件:

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *.svn') do (
rd /s /q "%%i"
)

save it in a file del_All_Dot_SVN_Folders.cmd . Run it. Your done.

将它保存在一个文件del_All_Dot_SVN_Folders中。cmd。运行它。你完成了。

Thanks to http://www.axelscript.com/2008/03/11/delete-all-svn-files-in-windows/

由于http://www.axelscript.com/2008/03/11/delete-all-svn-files-in-windows/

Remember the above code has .svn whereas the code in the link has only *svn so its better to have the .svn to not accidentally have undesired effect.

记住上面的代码有。svn,而链接中的代码只有*svn,所以最好有.svn,不要意外地产生不希望的效果。

#7


-1  

Here is my favorite, its simple and compact:

这是我的最爱,它简单紧凑:

find ./ -name ".svn" | xargs rm -Rf

找到。/ - name”。svn" | xargs rm -Rf。

Fissh

Fissh

#8


-2  

To delete all svn files on windows

要删除windows上的所有svn文件。

for /d /r . %d in (.svn) do @if exist "%d" rd /s/q "%d"

.svn is the folder name

.svn是文件夹的名称。