Powershell脚本仅将子文件夹中的文件移动到另一个位置,一次一个子文件夹
Powershell script to move only files in subfolder to another location ,one subfolder at a time
我正在处理 PowerShell 脚本,我们需要将子文件夹中的文件移动到另一个位置,一次移动一个子文件夹,即移动子文件夹 1 中的文件,等待 10 分钟,然后将文件从子文件夹 2 移动。
该脚本移动所有子文件夹中的文件
Get-ChildItem –Path "C:\PS\"*.HTML -Recurse | Foreach-Object {
Move-Item $_.FullName -Destination E:\work\tst.txt
}
文件夹结构:
Parent folder
Child1
file1.txt
file2.txt
file3.txt
Child2
file1.txt
file2.txt
file3.txt
Child3
file1.txt
file2.txt
file3.txt
然后使用Get-ChildItem
发现每个子文件夹:
Get-ChildItem -Path C:\PS -Directory |ForEach-Object {
# move files from this folder to destination
$_ |Get-ChildItem -File |Move-Item -Destination E:\work\ -Force
# wait 10 minutes
Start-Sleep -Seconds 600
}
我正在处理 PowerShell 脚本,我们需要将子文件夹中的文件移动到另一个位置,一次移动一个子文件夹,即移动子文件夹 1 中的文件,等待 10 分钟,然后将文件从子文件夹 2 移动。 该脚本移动所有子文件夹中的文件
Get-ChildItem –Path "C:\PS\"*.HTML -Recurse | Foreach-Object {
Move-Item $_.FullName -Destination E:\work\tst.txt
}
文件夹结构:
Parent folder
Child1
file1.txt
file2.txt
file3.txt
Child2
file1.txt
file2.txt
file3.txt
Child3
file1.txt
file2.txt
file3.txt
然后使用Get-ChildItem
发现每个子文件夹:
Get-ChildItem -Path C:\PS -Directory |ForEach-Object {
# move files from this folder to destination
$_ |Get-ChildItem -File |Move-Item -Destination E:\work\ -Force
# wait 10 minutes
Start-Sleep -Seconds 600
}