- 积分
- 215
- 最后登录
- 2024-3-31
- 精华
- 0
- 阅读权限
- 30
- 主题
- 85
- UID
- 1677795
- 帖子
- 538
- PB币
- 954
- 威望
- 0
- 贡献
- 0
- 技术
- 15
- 活跃
- 1321
- UID
- 1677795
- 帖子
- 538
- PB币
- 954
- 贡献
- 0
- 技术
- 15
- 活跃
- 1321
|
这个脚本是在网上搜集的,用于自动更换桌面壁纸为锁屏的聚焦壁纸,目的已经达到了,只是有些小问题!
add-type -AssemblyName System.Drawing
New-Item "$($env:USERPROFILE)\Pictures\Spotlight" -ItemType directory -Force;
New-Item "$($env:USERPROFILE)\Pictures\Spotlight\CopyAssets" -ItemType directory -Force;
New-Item "$($env:USERPROFILE)\Pictures\Spotlight\Horizontal" -ItemType directory -Force;
New-Item "$($env:USERPROFILE)\Pictures\Spotlight\Vertical" -ItemType directory -Force;
foreach($file in (Get-Item "$($env:LOCALAPPDATA)\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets\*"))
{
if ((Get-Item $file).length -lt 100kb)
{ continue }
Copy-Item $file.FullName "$($env:USERPROFILE)\Pictures\Spotlight\CopyAssets\$($file.Name).jpg";
}
foreach($newfile in (Get-Item "$($env:USERPROFILE)\Pictures\Spotlight\CopyAssets\*"))
{
$image = New-Object -comObject WIA.ImageFile;
$image.LoadFile($newfile.FullName);
if($image.Width.ToString() -eq "1920")
{
Move-Item $newfile.FullName "$($env:USERPROFILE)\Pictures\Spotlight\Horizontal" -Force;
}
elseif($image.Width.ToString() -eq "1080")
{
Move-Item $newfile.FullName "$($env:USERPROFILE)\Pictures\Spotlight\Vertical" -Force;
}
}
Remove-Item "$($env:USERPROFILE)\Pictures\Spotlight\CopyAssets\*";
我看不懂这个脚本
目前运行是通过系统的计划任务实现的
我想在里面加两个功能
1,每隔一个月清理一下图片文件夹下的图片
2,希望每次运行的时候能后台运行,不出现Windows PowerShell这个窗口。
谢谢
|
|