我必须编写一个脚本来检查后台批处理正在进行的文件传输的进度。我知道文件夹需要有多少文件才能处于"完成"状态。我正在尝试以下背景PHP:
$id = $_GET['id'];
$qtd = $_GET['qtd'];
checkProgress($id, $qtd);
function checkProgress($qtd, $id) {
$dirWav = "D:''path''to''wav''".$id."''";
$dirMP3 = "D:''path''to''mp3''".$id."''";
$progWav = array_diff( scandir($dirWav), array(".", "..") );
$progMP3 = array_diff( scandir($dirMP3), array(".", "..") );
$numWav = count($progWav);
$numMP3 = count($progMP3);
if ($numMP3 < $qtd OR $numWav < $qtd) {
sleep(5);
checkProgress($qtd, $id); //Here i'm trying to do it in a recursive way
} else {
//End script, record to the DB
}
}
我确信文件夹开始检查时是空的,并且批处理运行完美无瑕。但是在脚本开始时,它会自动转到末尾(我使用mkdir以一种惰性的方式检查它)。
我怎样才能达到我想要的?我不能通过cronjob之类的检查
这是Powershell,但我猜整个功能将适用于批处理文件。将输入作为两个路径,运行FOR循环对文件进行计数并进行比较。查看此处查看for循环中的文件计数。
Function Count-Folders{
Param
(
[parameter(Mandatory=$true,Position=1)][string]$source,
[parameter(Mandatory=$true,Position=2)][string]$dest
)
$path = @(gci -Path $source -dir)
$path2 = @(gci -Path $dest -dir)
If($path.Length -eq $path2.Length){
"Matches"
} Else{
"input folder counts do not match, check again!!!"
}