简体   繁体   中英

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 . 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

$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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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