简体   繁体   English

如何在PowerShell中复制文件夹x次?

[英]How to copy a folder x number of times in PowerShell?

I have a this little script that just copies a folder right now: 我有一个小脚本,现在只复制一个文件夹:

$NumberOfProfiles = Read-Host "Enter the number of Portable Firefox profiles You need:"
$WhereToWrite = $Source 
$Source = Get-Location 
$FolderName = "Apple"
$SourceDirectory = "$Source\$Foldername\*"
Copy-Item $SourceDirectory $WhereToWrite -Recurse

But I'd need it to copy x times that is defined in $NumberOfProfiles with Read-Host . 但是我需要它来复制$NumberOfProfiles具有Read-Host x次。 Also, for some reason it just copies the content of the folder itself but not the main folder. 同样,由于某种原因,它仅复制文件夹本身的内容,而不复制主文件夹。

Big thanks if anybody could lend a noobie a helping hand. 非常感谢任何人都可以帮助新手。

Somnething like this would get you the apple1,apple2...Applel0 像这样的Somnething会让你得到apple1,apple2 ... Applel0

$NumberOfProfiles = Read-Host "Enter the number of Portable Firefox profiles You need:"
$Source = "C:\source\"
$WhereToWrite = "C:\Dest\Apple"
for($i=1;$i -le $NumberOfProfiles;$i++){
$dest = "$WhereToWrite$i"
Copy-Item $Source $dest -Recurse
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM