如何在Windows命令提示符下删除特定目录中的文件/子文件夹 [英] How to delete files/subfolders in a specific directory at command prompt in Windows

查看:636
本文介绍了如何在Windows命令提示符下删除特定目录中的文件/子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我说,有一个叫变量%pathtofolder%,因为它明确它是一个文件夹的完整路径。

Say, there is a variable called %pathtofolder%, as it makes clear it is a full path of a folder.

我要删除这个目录中的每一个文件和子文件夹,而不是目录本身。

I want to delete every single file and subfolder in this directory, but not the directory itself.

但是,像'这个文件/文件夹已在使用...当这种情况发生,它应该只是继续跳过该文件/文件夹有可能是一个错误。

But, there might be an error like 'this file/folder is already in use'... when that happens, it should just continue and skip that file/folder.

谁能给我一些这方面的命令?

Can anyone give me some command for this?

推荐答案

我用这来清理所创建的临时文件夹:

I am using this to clean up the temp folder that are created:

FOR /D %%p IN ("C:\Temp\*.*") DO rmdir "%%p" /s /q

创建包含上面的命令的批处理文件(例如,delete.bat)。去那里的delete.bat文件所在的位置,然后运行命令:delete.bat

Create a batch file (say, delete.bat) containing the above command. Go to the location where the delete.bat file is located and then run the command: delete.bat

这篇关于如何在Windows命令提示符下删除特定目录中的文件/子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆