1. 首页>财经 > 财经

批处理文件格式(批处理文件)

作者:金龙东
2023年07月31日 17:05
财经

你们好,最近小元发现有诸多的小伙伴们对于批处理文件格式,批处理文件这个问题都颇为感兴趣的,今天小活为大家梳理了下,一起往下看看吧。

1、 打开记事本。记事本允许您将代码创建为文本文件,然后在完成后将其保存为批处理文件。可以右击打开记事本。

2、 记事本通常用于将文本文件转换为批处理文件,但您几乎可以在任何地方编写批处理文件的文本。

3、 学习一些基本的批处理命令。批处理文件运行一系列DOS命令,因此您可以使用的命令类似于DOS命令。一些更重要的问题包括:

4、 ECHO - --Displays text on the screen

5、 @ECHO OFF - --Hides the text that is normally output

6、 START --- Run a file with its default application

7、 REM --- Inserts a comment line in the program

8、 MKDIR/RMDIR - --Create and remove directories

9、 DEL - --Deletes a file or files

10、 COPY - --Copy a file or files

11、 XCOPY --- Allows you to copy files with extra options

12、 FOR/IN/DO --- This command lets you specify files.

13、 TITLE- --Edit the title of the window

14、 写一个程序来创建一个目录。学习如何创造的一个最简单的方法批处理文件就是先把注意力集中在基本任务上。例如,您可以使用批处理文件快速创建多个目录。

15、 MKDIR c:example1

16、 MKDIR c:example2

17、 写一个基本的备份程序代码。批处理文件是运行多个命令的理想选择,尤其是当您将其配置为多次运行时。使用xcopy命令,您可以创建一个批处理文件,

18、 将所选文件夹中的文件复制到备份文件夹,仅覆盖自上次复制以来已更新的文件:

19、 [@ Echo off

20、 XCOPYc:原始c:backupfolder /m /e /y】

21、 This copies over files from the folder 'original' to the folder

22、 'backupfolder'. You can replace these with the paths to the folders you

23、 want. /m specifies that only updated files will be copied, /e specifies that all subdirectories in the listed directory will be copied, and /y keeps the confirmation message appearing every time a file is overwritten.

24、 写一个更高级的备份程序。简单地将文件从一个文件夹复制到另一个文件夹是好的,但是如果你想同时对它们进行排序呢?这是for/in/do命令的功能。根据扩展名的不同,您可以使用此命令告诉文件的位置:

25、 @ECHO OFF

26、 cd c:source

27、 REM This is the location of the files that you want to sort

28、 FOR %%f IN (*.doc *.txt) DO XCOPY c:source'%%f' c:text /m /y

29、 REM This moves any files with a .doc or

30、 REM .txt extension from c:source to c:text

31、 REM %%f is a variable

32、 FOR %%f IN (*.jpg *.png *.bmp) DO XCOPY C:source'%%f' c:images /m /y

33、 REM This moves any files with a .jpg,png,

34、 REM or .bmp extension from c:source to c:images

35、 使用不同的批处理命令,您可以看看下面的测验。

36、 如果您想在批处理代码中添加一个仅复制更新文件的部分,应该在代码中添加什么?

37、 /m

38、 That's right! Adding the /m function will ensure only updated files are copied. Using /m in a basic program will allow your batch file to efficiently back up your data. Read on for another quiz question.

39、 /e

40、 Not quite! The /e function won't work to keep only updated files. Instead, use /e to specify that all your subdirectories in any listed directory should be copied. Try another answer.

41、 保存批处理文件

42、 完成批处理文件文本输入。整理校对后批处理文件,可以继续保存为可执行文件。

43、 点击“文件”。在记事本窗口的左上角。将出现一个下拉菜单。

44、 单击另存为。

45、 文件下拉菜单。点击它将提示另存为窗口打开。

46、 输入一个名称和"。蝙蝠”分机。在“文件名”文本框中,键入要命名的程序,然后键入。蝙蝠。

47、 例如,对于名为“1234”的程序,您可以在此处键入1234.bat。

48、 单击保存类型下拉框。您可以在“另存为”窗口的底部找到它。将出现一个下拉菜单。

49、 单击所有文件。在下拉菜单中。这将允许您的文件以其扩展名(".在这种情况下是bat)。

50、 单击另存为保存文件。

51、 编辑批处理文件的内容。您可以随时右键单击批处理文件,然后在生成的下拉菜单中单击编辑。这将作为记事本文件打开批处理文件;此时,您可以进行任何更改。

52、 然后按ctrl s保存文件。

以上就是批处理文件这篇文章的一些介绍,希望对大家有所帮助。

推荐阅读