DirCreate

新建一个目录/文件夹.

DirCreate ( "路径" )

 

参数

路径 要创建的目录路径.

 

返回值

成功: 返回值为1. 失败: 返回值为0,说明在创建目录的过程中遇到错误.

 

注意/说明

在要创建的目录的父目录(上一级目录)不存在时,这些父目录也会被创建.

 

相关

DirRemove, FileCopy

 

示例/演示


DirCreate("C:\Test1\Folder1\Folder2")


DirCopy

复制指定目录及其所有子目录和文件(类似于xcopy命令).

DirCopy ( "源目录", "目标目录" [, 标志] )

 

参数

源目录 要复制的文件夹的的路径(结尾不需反斜线符号).例如: "C:\Path1" 目标目录 要复制到的目标路径(结尾不需反斜线符号).例如: "C:\Path_Copy" 标志 [可选参数] 此标志参数用以决定是否覆盖已存在的文件:
 0 = (默认)不覆盖已存在的文件
 1 = 覆盖已存在的文件

 

返回值

成功: 返回 1. 失败: 如果有复制目录错误,返回 0 .

 

注意/说明

如果目标目录结构不存在,它将被创建(如果可能的话)..

 

相关

DirRemove, FileCopy

 

示例/演示


DirCopy(@MyDocumentsDir, "C:\Backups\MyDocs", 1)

DirMove

移动指定目录及其所有子目录和文件.

DirMove ( "源目录", "目标目录" [, 标志] )

 

参数

源目录 要移动的文件夹的路径(结尾不需反斜线符号).例如: "C:\Path1" 目标目录 要移动到的目标路径(结尾不需反斜线符号).例如: "C:\Path_Copy" 标志 [可选参数] 此标志参数用以决定是否覆盖已存在的文件:
 0 = (默认)不覆盖已存在的文件
 1 = 覆盖已存在的文件

 

返回值

成功: 返回值为1. 失败: 返回值为0,说明在移动目录的过程中遇到错误.

 

注意/说明

若源目录和目标目录位于不同的卷标或 UNC 路径已被使用,则本函数将执行复制/删除操作而不是直接移动.

若目标目录已存在并指定了覆盖标志(参数),则源目录将被移动到目标目录 里面.

由于 AutoIt,并没有"DirRename" (目录重命名)函数,请使用 DirMove 函数来重命名文件夹!

 

相关

DirRemove, FileMove

 

示例/演示


DirMove(@MyDocumentsDir, "C:\Backups\MyDocs")

DirRemove

删除一个目录/文件夹.

DirRemove ( "路径" [, 递归遍历] )

 

参数

路径 要删除的文件夹的路径. 递归遍历 [可选参数] 此标志参数用以决定是否删除子目录.
  0 = (默认)不删除文件及子目录
  1 = 删除文件及子目录(类似于 DOS 下的 DelTree 命令)

 

返回值

成功: 返回值为1. 失败: 返回值为0,说明在删除目录的过程中遇到错误(或者指定目录并不存在).

 

注意/说明

一些目录属性会导致无法移除.

 

相关

DirCreate, FileRecycle, DirCopy, DirMove, FileDelete

 

示例/演示


; 删除 C:\Test1 及其所有子目录和文件.
DirRemove("C:\Test1", 1)


 DirGetSize

返回给点目录所占用的空间(单位字节).

DirGetSize ( "路径" [, 标志] )

 

参数

路径 要得到文件大小占用的目录, 例如. "C:\Windows". 标志 [可选参数] 此标志决定了本函数的行为及结果,它的值可以是下列数值的组合(数值相加):
0 = (默认)
1 = 启用扩展模式 -> 返回一个包含扩展信息的数组(请查看下面的 注意部分).
2 = 子目录下的文件大小将不计算入内(递归模式被取消)

 

返回值

成功: 返回值 >= 0,占用空间的大小. 失败: 返回 -1,并把 @error 设为 1, 说明目标路径并不存在.

 

注意/说明

如果脚本程序被暂停则此函数也随之暂停,直到脚本恢复执行为止!

在使用扩展模式时,本函数所返回的数组是个含有下列元素的一维数组:
$array[0] = 空间大小
$array[1] = 文件数
$array[2] = 文件夹数

 

相关

没有.

 

示例/演示


$size = DirGetSize(@HomeDrive)
Msgbox(0,"","大小(MB) :" & Round($size / 1024 / 1024))

$size = DirGetSize(@WindowsDir, 2)
Msgbox(0,"","大小(MB) :" & Round($size / 1024 / 1024))

$timer  = TimerInit()
$size   = DirGetSize("\\10.0.0.1\h$",1);试试填入一个真实路径
$diff   = Round(TimerDiff($timer) / 1000)   ; 按秒计时
If IsArray($size) Then
    Msgbox(0,"DirGetSize-信息","大小(字节):" & $size[0] & @LF _
        & "文件:" & $size[1] & @LF & "文件夹:" & $size[2] & @LF _
        & "用时(秒):" & $diff)
EndIf


 

Macro Description Macros for "All Users" data. @AppDataCommonDir path to Application Data @DesktopCommonDir path to Desktop @DocumentsCommonDir path to Documents @FavoritesCommonDir path to Favorites @ProgramsCommonDir path to Start Menu's Programs folder @StartMenuCommonDir path to Start Menu folder @StartupCommonDir path to Startup folder
Macros for Current User data. @AppDataDir path to current user's Application Data @DesktopDir path to current user's  Desktop @MyDocumentsDir path to My Documents target @FavoritesDir path to current user's Favorites @ProgramsDir path to current user's Programs (folder on Start Menu) @StartMenuDir path to current user's Start Menu @StartupDir current user's Startup folder @UserProfileDir Path to current user's Profile folder.
Other macros for the computer system: @HomeDrive Drive letter of drive containing current user's home directory. @HomePath Directory part of current user's home directory. To get the full path, use in conjunction with @HomeDrive. @HomeShare Server and share name containing current user's home directory. @LogonDNSDomain Logon DNS Domain. @LogonDomain Logon Domain. @LogonServer Logon server. @ProgramFilesDir path to Program Files folder @CommonFilesDir path to Common Files folder @WindowsDir path to Windows folder @SystemDir path to Windows' System (or System32) folder @TempDir path to the temporary files folder @ComSpec value of %comspec%, the SPECified secondary COMmand interpreter;
primarly for command line uses, e.g.  Run(@ComSpec & " /k help | more")

 





没有登录不能评论