Import-Module PSWriteColor
echo 'tits'
#Directory Variables
switch ($env:COMPUTERNAME){
    "WORKSTATION"
    {
        $baseDir = 'D:\OneDrive\Pictures\MyArt'
    }
    "SURFACE"    
    {
        $baseDir = 'C:\Users\JawZ\Pictures\My Art'
    }
}
$template = "$baseDir\Assets\Template.clip"
$month = Get-Date -UFormat %B
$year = Get-Date -Format yyyy

function Write-Separator{Write-Color '---' -Color DarkGray}

function New-Patreon{
    $directory = "$baseDir\Patreon"
    Set-Location $directory

    Write-Color 'Add number ', '(type 0x)' -Color Yellow, White
    $number = Read-Host
    
    Switch ($month){
        '1'  {$month = 'Jan'}
        '01' {$month = 'Jan'}
        '2' {$month = 'Feb'}
        '02' {$month = 'Feb'}
        '3' {$month = 'Mar'}
        '03' {$month = 'Mar'}
        '4' {$month = 'Apr'}
        '04' {$month = 'Apr'}
        '5' {$month = 'May'}
        '05' {$month = 'May'}
        '6' {$month = 'Jun'}
        '06' {$month = 'Jun'}
        '7' {$month = 'Jul'}
        '07' {$month = 'Jul'}
        '8' {$month = 'Aug'}
        '08' {$month = 'Aug'}
        '9' {$month = 'Sep'}
        '09' {$month = 'Sep'}
        '10' {$month = 'Oct'}
        '11' {$month = 'Nov'}
        '12' {$month = 'Dec'}
    }

    $dirName = $month + '_' + $number
    $file = $dirName + ' [x].clip'
    mkdir $dirName
    Copy-Item "$template" "$directory\$dirName\$file"
    Set-Location $directory\$dirName\
    Invoke-Item .
    & ./$file
}

function New-Commission{
    $directory = "$baseDir\Commissions\"
    Set-Location $directory
    
    Write-Color 'Who is the commissioner?' -Color Yellow
    $user = Read-Host
    Write-Color 'Add number ', '(type 0x)' -Color Yellow, White
    $number = Read-Host
    if(!(Test-Path $user)){
        mkdir $user
    }
    $file = '[com] ' + $user + '_' + $number + ' [x].clip'
    Copy-Item $template "$user\$file."
    Set-Location $directory\$user
    Invoke-Item .
    & ./$file
}

function New-Personal{
    Set-Location $baseDir
    Write-Color 'Type filename:' -Color Yellow
    $file = Read-Host
    Copy-Item "$template" ./$file.clip
    Invoke-Item .
    & ./$file.clip
}

function New-Paste{
    Clear-Host
    Write-Color '1) ', 'Suggestion' -Color White, Magenta
    Write-Color '2) ', 'Poll (Pin-up)' -Color White, Magenta
    Write-Color '3) ', 'Poll (Illustration)' -Color White, Magenta
    Write-Color '4) ', 'Pin-up' -Color White, Magenta
    Write-Color '5) ', 'Illustration' -Color White, Magenta
    Write-Separator
    $option2 = Read-Host
    Write-Separator
    switch ($option2) {
        '1'{
            $clip = $month + ' Suggestion time!'
            $clip
            $clip | clip
        }
        '2'{
            $clip = $month + ' Pin-Up poll!'
            $clip
            $clip | clip
        }
        '3'{
            $clip = $month + ' Illustration poll!'
            $clip
            $clip | clip
        }
        '4'{
            $clip = $month + ' Pin-up #X (WIP X)'
            $clip
            $clip | clip
        }
        '5'{
            $clip = $month + ' Illustration #X (WIP X)'
            $clip
            $clip | clip
        }
    }
}

function Anonymator{
    $nameConflict = @(
        'Ronny'
        'Tetractys'
        'tonio4316'
	)
	$nameFix = @(
        'Anony'
        'Anonctys'
        'Anon4316'
	)
	#Rename directories
	for ($i = 0; $i -lt $nameConflict.Count; $i++){
		$nameFilter = '*' + $nameConflict[$i] + '*'
		foreach ($conflictName in Get-ChildItem -Recurse -Directory -Filter $nameFilter){
			$newDir = $conflictName.Name.Replace($nameConflict[$i], $nameFix[$i])
			if(Test-Path ($newDir)){
				foreach ($file in Get-ChildItem -Path $conflictName){Move-Item $file -Destination $newDir}
			}
			elseif(!(Test-Path ($newDir))){
				Write-Separator
				Write-Color 'Will rename the directory ', $conflictName.Name, ' into ', $newDir -Color White, Red, White, Green
				Rename-Item $conflictName -NewName $newDir
			}
		}
		foreach ($conflictName in Get-ChildItem $nameFilter -File -Recurse){
			Write-Color $conflictName.Name, " will be renamed into ", $conflictName.Name.Replace($nameConflict[$i], $nameFix[$i]) -Color Red, White, Green
			Rename-Item $conflictName.FullName -NewName $conflictName.Name.Replace($nameConflict[$i], $nameFix[$i])
		}
	}
}

Write-Color '1) ', 'Patreon' -Color White, Magenta
Write-Color '2) ', 'Commission' -Color White, Magenta
Write-Color '3) ', 'Personal' -Color White, Magenta
Write-Color '4) ', 'Patreon title' -Color White, Magenta
Write-Color '5) ', 'Anonymator' -Color White, Magenta
Write-Separator
$option = Read-Host
Write-Separator

Switch ($option){
    "1" {New-Patreon}
    "2" {New-Commission} 
    "3" {New-Personal}
    "4" {New-Paste}
    "5" {Anonymator}
}