不清楚你的实际文件/情况,仅以问题中的说明及猜测为据
复制粘贴到记事本,另存为xx.bat,编码选ANSI
<# :
cls
@echo off
rem 将修改时间在最近一小时以内的文件复制/拷贝到一个新的文件夹/目录里
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default))) -Args '%~dp0'"
echo;%#% +%$%%$%/%@% %z%
pause
exit
#>
$oldfolder='D:\xxx\原文件夹';
$newfolder='E:\yyy\新文件夹';
if(-not (test-path -liter $oldfolder)){write-host ('"'+$oldfolder+'" not found');exit;};
$agetime=(get-date).AddSeconds(-3600);
$files=@(dir -liter $oldfolder -recurse|?{$_ -is [System.IO.FileInfo]});
for($i=0;$i -lt $files.length;$i++){
if($files[$i].LastWriteTime -ge $agetime){
$newpath=$newfolder.trimend('\')+$files[$i].Directory.FullName.Substring($oldfolder.length);
$newfile=$newpath+'\'+$files[$i].Name;
if(-not (test-path -liter $newpath)){
[void](md $newpath -force);
};
write-host ($files[$i].FullName+' --> '+$newpath);
};
};