Created
March 28, 2015 18:18
-
-
Save iOnline247/7d880e2cea73f71ce9b1 to your computer and use it in GitHub Desktop.
Create 21,000 folders and 21,000 files for funsies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create 21,000 folders and 21,000 txt files. | |
# Add one file per folder. | |
# Folder names will be sequential. | |
# File names will start with a GUID and end with a timestamp. | |
# This is to try and prove if ODB is FIFO and not any other way. | |
param( | |
[parameter(mandatory=$true)] | |
[string]$filePath | |
) | |
$numOfIterations = 0 | |
# Clean directory | |
Get-ChildItem -Path $filePath -Recurse | Remove-Item -Recurse -Confirm:$true | |
while($numOfIterations++ -lt 21000) { | |
$guid = [guid]::NewGuid() | |
$tick = (Get-Date).Ticks | |
$currentPrefix = $($guid.ToString() + '#;' + $tick) | |
$folderPath = "$($filePath)" + "\" + "$($numOfIterations)" | |
# Create folder. | |
md -Path $folderPath -Force | |
# Create file. | |
[guid]::NewGuid().ToString() | Out-File $($filePath + "\" + $currentPrefix + ".txt") -Force | |
} | |
# Sort files based on numeric sort. | |
# $arrayOfStrings | Sort-Object { $_.substring($_.lastIndexOf("#;") +2) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment