本帖最后由 zaqmlp 于 2019-12-30 18:24 编辑
- <# :
- cls
- @echo off
- set info=互助互利,支付宝扫码头像,感谢赞助
- rem 有问题,可加QQ956535081及时沟通
- title %info%
- powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default)))"
- echo;%info%
- pause
- exit
- #>
-
- #文件夹路径
- $folder='D:\xxx\yyy';
-
- #文件及修改日期
- $list=@{
- '1.txt'='2019-01-01';
- '2.rar'='2019-10-23';
- '3.jpg'='2019-03-03';
- 'xx.mp4'='2019-03-17'
- };
-
- if(-not (test-path -liter $folder)){write-host ('"'+$folder+'" not found');exit;};
- $files=@(dir -liter $folder|?{$_ -is [System.IO.FileInfo]});
- for($i=0;$i -lt $files.length;$i++){
- if($list.ContainsKey($files[$i].Name)){
- $old=$files[$i].LastWriteTime;
- $new=(get-date ($list[$files[$i].Name]+' '+$old.toString('HH:mm:ss')));
- $files[$i].LastWriteTime=$new;
- write-host ('['+$old.toString('yyyy-MM-dd HH:mm:ss')+'-->'+$new.toString('yyyy-MM-dd HH:mm:ss')+']'+$files[$i].Name);
- };
- };
复制代码
|