Programing

deltree에 무슨 일이 일어 났고 그 대체물은 무엇입니까?

crosscheck 2020. 10. 19. 07:45
반응형

deltree에 무슨 일이 일어 났고 그 대체물은 무엇입니까?


이전 버전의 MS-DOS에서는 버전 7이라고 말하고 싶지만 틀릴 수 있습니다. deltree명령 이 있었는데 , 주어진 경로에서 모든 하위 디렉터리와 파일을 재귀 적으로 삭제했습니다.

deltree더 이상 존재 del하지 않지만 나무를 삭제할 수있는 능력을 상속하지 않는 것 같습니다. del /s파일을 삭제하지만 폴더는 삭제하지 않습니다.

배치 파일에서 트리를 쉽게 (즉, 하나의 명령으로) 삭제하는 방법은 무엇입니까?


다른 사람들이 언급했듯이 rd명령에는 /s하위 디렉터리를 재귀 적으로 제거 하는 스위치가 있습니다. 이를 /q스위치 와 결합하여 메시지를 표시하지 않고 하위 디렉토리 (및 해당 내용)를 강제로 삭제할 수 있습니다.

rd /s /q c:\foobar

모두가 빠진 것은 인터넷 검색이 반환하는 모든 페이지가 ( 거의 ) 겉보기에 ( 거의 ) 모든 페이지에 대한 정확한 대체 rd아니라는 것입니다. 명령은 디렉토리 와 파일 모두에 대해 작동 하여 하나의 편리한 다목적 삭제 명령이되었습니다. 다음 두 가지가 모두 유효합니다.deltreewindows deltreedeltree

deltree /y c:\foobar
deltree /y c:\baz.txt

그러나 rd(당연히) 디렉토리에서만 작동합니다 . 따라서 다음 명령 중 첫 번째 명령 만 유효하고 두 번째 명령은 오류를주고 파일을 삭제되지 않은 상태로 둡니다.

rd /s /q c:\foobar
rd /s /q c:\baz.txt

또한 del명령은 디렉토리가 아닌 파일에 대해서만 작동하므로 두 번째 명령 만 유효하고 첫 번째 명령은 오류를 제공합니다.

del /f /q c:\foobar
del /f /q c:\baz.txt

에서 수행 할 수있는 파일 및 디렉토리를 삭제하는 기본 제공 방법은 없습니다 deltree. rddel개별적으로 사용 하는 것은 파일 시스템 객체 (파일 / 폴더 이름)가 항상 가능하거나 실용적이지 않은 파일 또는 디렉토리인지 구별해야하기 때문에 기껏해야 불편합니다.

deltree이전 OS에서 명령을 복사 할 수 있지만 16 비트 DOS 명령 (Windows 9x에서도)이므로 32 비트 버전의 Windows에서만 작동합니다.

또 다른 옵션은 del모두를 호출하는 배치 파일을 만드는 것입니다 rd. 이 같은:

::deltree.bat

@echo off
rd  %* 2> nul
del %* 2> nul

다음과 같이 호출합니다.

deltree.bat /s /q /f c:\foobar
deltree.bat /s /q /f c:\baz.txt

이렇게하면 rd둘 다 호출 del하여 인수를 전달하고 출력을 nul리디렉션하여 둘 중 하나가 항상 발생하는 오류를 방지합니다.

매개 변수를 수용하거나 단순화하거나 오류 메시지를 허용하도록 동작을 사용자 정의하고 싶을 것입니다.하지만 그렇다고하더라도 deltree.

대안은 타사 도구를 얻는 것입니다. 그러나 하나를 찾는 것은 검색 쿼리 작성에서 실제 연습입니다.


RMDIR 또는 RD 명령으로 대체되었습니다.

/ S를 사용하여 모든 하위 디렉터리 삭제

/ Q와 함께 조용히 사용

예:

RMDIR /S /Q Folder2Delete
RD /S /Q Folder2Delete

선적 서류 비치:


향수를 불러 일으키는 느낌으로 내 자신의 deltree.exe를 작성했습니다. 디렉터리와 파일 모두에서 작동하며 속도를 위해 SHFileOperation ()을 사용합니다.

https://github.com/ai7/toolbox/tree/master/deltree

deltree v1.01 [Mar 27 2015, 16:31:02] (gcc 4.9.1)

Usage: deltree [options] <path> ...

Options:
  -y    yes, suppresses prompting for confirmation
  -s    silent, do not display any progress dialog
  -n    do nothing, simulate the operation
  -f    force, no prompting/silent (for rm compatibility)
  -r    ignored (for rm compatibility)

Delete directories and all the subdirectories and files in it.

와일드 카드가 필요하며 unix rm처럼 사용할 수 있습니다.

deltree -rf *

rmdir /s /q directory

$ help rd
디렉토리를 제거 (삭제)합니다.

RMDIR [/ S] [/ Q] [드라이브 :] 경로
RD [/ S] [/ Q] [드라이브 :] 경로

    /S      Removes all directories and files in the specified directory
            in addition to the directory itself.  Used to remove a directory
            tree.

    /Q      Quiet mode, do not ask if ok to remove a directory tree with /S

Nowadays, you can use Powershell to do the same task:

powershell -Command "Remove-Item 'PathToMyDirectory\*' -Recurse -Force"

Actually RMDIR and RD commands in modern Windows operating system merge both the commands RD and Deltree of Win 98 in a single command. It's an internal command that's why you won't find any RD.exe and RMDIR.exe.

By typing this "RD /?" in cmd without double qoutes you'll get exactly what you want.


to delete a directory and all it's contents recursively

rd /s MY_DOOMED_DIR

Use this:

cd (your directory here)
del *.* /f /s /q

Delete all files and subdirectories

cd /d Directory && rd /s /q .\

참고URL : https://stackoverflow.com/questions/338895/what-ever-happened-to-deltree-and-whats-its-replacement

반응형