#连接到远程服务器(当前被注释)
#net use \\10.100.1.1\ipc$ "aaa" /user:"administrator"
$IniFile="D:\WORK\LastExecuteTime.ini"
$PathFrom="D:\WORK\データ元\"
$PathTo="D:\WORK\データ先\"
$DateTime=type $IniFile
Get-ChildItem $PathFrom *.dat | ForEach-Object -Process{
if($_ -is [System.IO.FileInfo] -and ($_.CreationTime.ToString('yyyyMMddHHmmss') -ge $DateTime)) {
$file=$PathFrom+$_.name
Write-Host($_.name,$_.CreationTime.ToString('yyyyMMddHHmmss'));
Write-Host($file);
copy $file $PathTo
}
}
Get-Date -Format 'yyyyMMddHHmmss' | Out-File $IniFile
#以下为调试代码
$string = "mtbill_post_201709141058.dat"
$regex = "\d{12}(?=\.dat)"
[regex]::matches($string, $regex).value
$string.Substring($string.IndexOf('.dat')-12, 12)