Jump to content

Test Powershell: Difference between revisions

Content deleted Content added
Created page with "<syntaxhighlight lang="powershell"> Function Get-FileName($initialDirectory) { [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog $OpenFileDialog.initialDirectory = $initialDirectory $OpenFileDialog.filter = "All bz2 files (*.bz2)| *.bz2" $OpenFileDialog.ShowDialog() | Out-Null $OpenFileDialog.filename } #end function Get-FileName # *** Script MAIN *** Write-Ho..."
 
No edit summary
 
Line 13: Line 13:
# *** Script MAIN ***
# *** Script MAIN ***


Write-Host "rebuilding MLEB bz2 to gz" -ForegroundColor black -BackgroundColor green
Write-Host -BackgroundColor green "rebuilding MLEB bz2 to gz\n"
Write-Host


$Pathscript = $PSScriptRoot
$Pathscript = $PSScriptRoot
$Pathbz2 = Split-Path -Parent $Pathscript
$Pathbz2 = Split-Path -Parent $Pathscript


Write-Host "scriptPath:" $Pathscript
Write-Host "scriptPath: $Pathscript "
Write-Host "bz2Path:" $Pathbz2
Write-Host "bz2Path: $Pathbz2 "
Write-Host


$filename = Get-FileName -initialDirectory "$Pathbz2"
$filename = Get-FileName -initialDirectory "$Pathbz2"
Line 29: Line 31:
Write-Host "converting $filename to a gz file"
Write-Host "converting $filename to a gz file"
#-split "red yellow blue green"
#-split "red yellow blue green"
$MLEBdate = $filename.Split("-")[2] -Split(".tar.bz2")
Write-Host "filename: $filename"
#$filename.Split("-")[2] -Split(".tar.bz2")
#$filename.Split("-").Split(".tar.bz2")


$fdate = $filename.Split("-").Split(".tar.bz2")
Write-Host "mkdir $Pathbz2/temp"
$fdate = $fdate[1]
New-Item -Path $Pathbz2/temp -ItemType directory -Force
cd $Pathbz2/temp
#Write-Host "Date is" $fdate

ls
Write-Host ""unpacking $filename"" tar -xvf $filename
Write-Host "creating temp directory"
New-Item -Path $Pathbz2\temp -ItemType directory -Force
Remove-Item $Pathbz2\temp\* -Recurse -Force
Set-Location -Path $Pathbz2\temp
# ls
Get-Childitem -Path $Pathbz2\temp
Write-Host "unpacking $filename" tar -xvf
tar -xf $filename
tar -xf $filename
Read-Host "hit enter to continue"
Write-Host "packing MLEB-$fdate.tar.gz"
tar -czf MLEB-$MLEBdate.tar.gz ./INSTALL.MediaWikiLanguageExtensionBundle -C extensions *
tar -czf MLEB-$fdate.tar.gz INSTALL.MediaWikiLanguageExtensionBundle -C extensions *

Copy-Item "MLEB-$fdate.tar.gz" -Destination "$Pathbz2"

#transfer file
}
}
#Write-Host "Write-Host"
#Write-Host "Write-Host"
Line 44: Line 59:
#Write-Progress -Activity "Search in Progress" -Status "10% Complete:"
#Write-Progress -Activity "Search in Progress" -Status "10% Complete:"
#Write-Progress -Activity "Search in Progress" -Status "20% Complete:"
#Write-Progress -Activity "Search in Progress" -Status "20% Complete:"

$Age = Read-Host "hit enter to continue"
Read-Host "hit enter to continue"
</syntaxhighlight>
</syntaxhighlight>