批处理删除文件夹命令_批处理文件夹命令

批处理删除文件夹命令

批处理文件夹命令 (Batch File Folder Commands)

1. Dir 2. Mkdir 3. Rmdir 4. Chdir 5. Ren 6. Pushd 7. Popd

1. Dir 2. Mkdir 3. Rmdir 4. Chdir 5. Ren 6. Pushed 7. Popd

指挥官 (Dir Command)

The dir command serves to print the contents in a directory. As usual like all other commands, this also has some switches that narrow down the results according to the switches used.

dir命令用于在目录中打印内容。 像所有其他命令一样,它也具有一些开关,这些开关可以根据使用的开关来缩小结果范围。

Eg: C:Usersuser1>dir

例如: C:Usersuser1> dir

Executing the dir command without any switches gives the following output.

在没有任何开关的情况下执行dir命令将产生以下输出。

Volume in drive C is OS Volume Serial Number is C484-3F97 Directory of C:Usersuser1 03/04/2014  07:40 AM    <DIR>          dwhelper 03/12/2015  05:57 PM    <DIR>          Favorites 0 File(s)              0 bytes 31 Dir(s)  137,566,859,264 bytes free

驱动器C中的 为OS 卷序列号为C484-3F97 C: Usersuser1 目录2014年 4月4日上午7:40 <DIR> dwhelper 2015年 3月 12 日05:57 PM <DIR>收藏夹 0文件0字节 31个dir 137,566,859,264字节可用

Initially it prints the drive details and then the contents in a table format. The first column gives the created date of either the file or the folder, Next column indicates the time of creation, then follows the <DIR> that indicates it is a folder. Finally the last column displays the column name. At last the number of files, directories and free memory space available on the drive is displayed.

最初,它先打印驱动器详细信息,然后以表格格式打印内容。 第一列给出了文件或文件夹的创建日期,下一列表明了创建时间,然后在<DIR>之后表明它是文件夹。 最后,最后一列显示列名。 最后显示驱动器上可用的文件,目录和可用存储空间的数量。

Flags in Dir Command dir command with ‘/a’ switch will display all the files and folders in a directory, no matter what attribute is set.

无论设置了什么属性,Dir Command dir命令中带有“ / a”开关的标志都将显示目录中的所有文件和文件夹。

‘dir /a[D|R|H|A|S|I]’ Switches description is as follows. ‘D’ to display Directories, ‘R’ to display Read-only files, ‘H’ to display Hidden files, ‘A’ to display Files ready for archiving, ‘S’ to display System files and ‘I’ to display not content indexed files.

'dir / a [D | R | H | A | S | I]'开关说明如下。 “ D”显示目录,“ R”显示只读文件,“ H”显示隐藏文件,“ A”显示准备归档的文件,“ S”显示系统文件,“ I”显示不内容索引文件。

‘dir /b’ Here ‘b’ stands for bare information. This serves similar purpose of dir command but only the folders and files are displayed in a single column without their extensions, date and time.

'dir / b'这里的'b'代表裸露的信息。 这与dir命令的目的相似,但只有文件夹和文件显示在单列中,没有扩展名,日期和时间。

‘dir /d’ command simply displaying the file names with their extensions alone.

'dir / d'命令仅显示带有扩展名的文件名。

‘dir /l’ displays the output in lowercase.

'dir / l'以小写形式显示输出。

‘dir /o’ sorts the order of files and folders.

'dir / o'排序文件和文件夹的顺序。

Mkdir命令 (Mkdir Command)

The mkdir command stands for to make a directory, which is used to create new directories in the desired location. Also the mkdir command is a replacement of the ‘md’ command. We can create any number of directories just by using a single mkdir command. This command doesn’t have any switches.

mkdir命令代表建立目录,该目录用于在所需位置创建新目录。 同样,mkdir命令代替了'md'命令。 我们只需使用一个mkdir命令就可以创建任意数量的目录。 该命令没有任何开关。

Eg: mkdir My Programs (or) Md My Programs

例如: mkdir我的程序(或)Md我的程序

The above two commands create a new directory named My Programs in the location where you are currently working. We can also create a folder inside another folder at the same time using a single command as the below one.

上面的两个命令在您当前工作的位置创建一个名为“我的程序”的新目录。 我们还可以使用下面的单个命令同时在另一个文件夹中创建一个文件夹。

Eg: md new1\new2\new3

例如: md new1 \ new2 \ new3

This command creates new1 folder then creates new2 inside new1 and at last new3 inside new2.

此命令创建new1文件夹,然后在new1内部创建new2,最后在new2内部创建new3。

Rmdir命令 (Rmdir Command)

The rmdir command is short hand for the remove directory that is used to remove an already existing directory or folder, you can use the command as ‘rd’ also which serves for the same purpose. For deleting a folder using rd command we need to make sure that it does not contain any files or sub folders.

rmdir命令是用于删除目录的快捷方式,该目录用于删除已经存在的目录或文件夹,您也可以将命令用作“ rd”,该命令也用于相同的目的。 要使用rd命令删除文件夹,我们需要确保该文件夹不包含任何文件或子文件夹。

Eg: rd new1

例如: rd new1

The above command doesn’t delete the folder new1 as already their exits a folder new2 inside new1. So, we use two switches to solve this problem. The rd command has two switches ‘/s’ and ‘/Q’. The ‘/s’ switch is used to delete all the directories, sub-directories and files inside the folder. So, you won’t have to manually delete all the sub folders and files inside them. The next switch ‘/Q’ stands for quiet mode, in quiet mode the command doesn’t prompt you for confirmation and does all the task of deleting silently.

上面的命令不会删除文件夹new1,因为它们已经退出了new1内的文件夹new2。 因此,我们使用两个开关来解决此问题。 rd命令有两个开关“ / s”和“ / Q”。 “ / s”开关用于删除文件夹中的所有目录,子目录和文件。 因此,您不必手动删除其中的所有子文件夹和文件。 下一个开关“ / Q”代表安静模式,在安静模式下,该命令不会提示您进行确认,而是执行所有删除操作。

Chdir命令 (Chdir Command)

The chdir command is used to change the current working directory. It can also be used in short as ‘cd’. The small difference between cd and chdir is that the chdir command doesn’t require the path given to be in quotes when the folder names contains spaces. But in case of cd command, it is necessary to give the path in quotes.

chdir命令用于更改当前工作目录。 它也可以简称为“ cd”。 cd和chdir之间的细微差别是,当文件夹名称包含空格时,chdir命令不需要给定的路径用引号引起来。 但是,如果使用cd命令,则必须用引号将路径引起来。

Eg: chdir  programsstart menu cd  “programsstart menu”

例如: chdirprogramsstart菜单cd“ programsstart菜单”

The above commands change the current working directory into start menu directory. Also we can use command ‘cd..’ to move one level up in the hierarchy of directories. And ‘cd’ to move into the current drive.

上面的命令将当前工作目录更改为开始菜单目录。 我们还可以使用命令“ cd ..”在目录层次结构中上移一级。 和“ cd”移动到当前驱动器。

任统帅 (Ren Command)

Rename command ‘ren’ is used to rename a directory on windows through the dos shell. ren can be replaced with its longer version as ‘rename’. The following example shows the syntax for renaming a folder.

重命名命令“ ren”用于通过dos外壳在Windows上重命名目录。 可以用较长版本的“重命名”代替ren。 以下示例显示了重命名文件夹的语法。

Eg: rename programmer crazyprogrammer

例如:将程序员重命名为crazyprogrammer

The above command renames the directory ‘programmer’ to ‘crazyprogrammer’. This command doesn’t have any switches.

上面的命令将目录“ programmer”重命名为“ crazyprogrammer”。 该命令没有任何开关。

推入和弹出命令 (Pushd and Popd Commands)

The pushd command is used to push the working directory or any specified directory. The current working directory is pushed into the stack and remains there until it is popped out. The popd command is used to pop out a directory that is pushed using the pushd command. Let us consider the below command to understand in detail.

pushd命令用于推送工作目录或任何指定目录。 当前的工作目录被推入堆栈,并保持在那里直到弹出。 popd命令用于弹出使用pushd命令推送的目录。 让我们考虑下面的命令来详细了解。

Eg: Assume that I’m in ‘C:myfolder’ and I want to push directly to ‘C:windows’. I can do so using the following command

例如:假设我在'C:myfolder'中,并且我想直接推送到'C:windows'。 我可以使用以下命令进行操作

Pushd C:windows

推入C:windows

Then my current working directory changes to ‘C:windows’ and the path ‘C:myfolder’ gets pushed into the stack. Next when I execute a popd command, my working directory changes to ‘C:myfolder’ as it pops out from the stack.

然后,我当前的工作目录更改为“ C:windows”,路径“ C:myfolder”被压入堆栈。 接下来,当我执行popd命令时,我的工作目录会从堆栈中弹出,更改为“ C:myfolder”。

C:windows> popd C:myfolder>

C:windows>弹出C:myfolder>

Try it yourself Create a directory and apply all the commands over it, observe and note down the results.

自己尝试创建目录并在其上应用所有命令,观察并记录结果。

翻译自: https://www.thecrazyprogrammer.com/2015/07/batch-file-folder-commands.html

批处理删除文件夹命令

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值