Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 在批处理脚本中查找大文件并将其移动到其他文件夹_Powershell_Batch File - Fatal编程技术网

Powershell 在批处理脚本中查找大文件并将其移动到其他文件夹

Powershell 在批处理脚本中查找大文件并将其移动到其他文件夹,powershell,batch-file,Powershell,Batch File,我需要一个与此powershell代码等效的批处理脚本。我编写了这个powershell脚本,但我不知道如何将其写入批处理脚本。请帮忙!这真让我沮丧。我如何搜索大文件,当我找到它时,我需要将其移动到其他文件夹 $Message = "FOUND HUGE FILES!!!" $AlertType = "Error" $ComputerName = "server1" gci D:\files | where {$_.length -gt 50mb} | foreach-object { m

我需要一个与此powershell代码等效的批处理脚本。我编写了这个powershell脚本,但我不知道如何将其写入批处理脚本。请帮忙!这真让我沮丧。我如何搜索大文件,当我找到它时,我需要将其移动到其他文件夹

$Message = "FOUND HUGE FILES!!!"
$AlertType = "Error" 
$ComputerName = "server1"

gci D:\files | where {$_.length -gt 50mb} |
foreach-object {

move-item -path $_.fullname -destination "D:\folder"

Write-eventlog -logname Application -Source Application -eventID 1009 -entrytype Information -Message $Message 

}
试试这个:

set message=FOUND HUGE FILES!!!
Set alerttype=Error
Set computername=server1

Pushd d:\files
For %%a in (*) do (
  If %%~za GTR 50000000 (
     Move "%%a" d:\folder
Eventcreate /ID 1009 /L APPLICATION /T INFORMATION /SO information /D "%message%"
  )
)
Popd

Batch math只能解析最大为2 GB的文件2^31-1请注意,对于大于2 GB的文件,此操作将失败。