开发者

Delete files and folders in a specified folder

I want to delete 开发者_如何学Pythonall files and folders in a specified folder. The end result should be that the folder is not deleted itself, just empty. In the linux world it is:

rm -rf /home/kasper/*

I have tried del, deltree and rd without luck. They either just delete files or delete everything including the folder itself.


this script inside your folder should solve it:

    for /D %%F in (*) do  ( rmdir /s/q .\%%~F)
    del /q *.*


rmdir /s/q  folder


Assuming you are running Windows.

The basic command line tools in Windows are rather limited. However, you can do this and many other tasks easily in PowerShell:

remove-item C:\test\* -recurse

If you prefer the Linux way, you can use UnxUtils, which is a collection of Unix command line tools natively compiled for Windows. I always have these in my PATH.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜