Skip to content

Instantly share code, notes, and snippets.

@a4099181
Last active September 24, 2018 14:48
Show Gist options
  • Save a4099181/0e4f17c78bedc7eca89c78c110f6aaa5 to your computer and use it in GitHub Desktop.
Save a4099181/0e4f17c78bedc7eca89c78c110f6aaa5 to your computer and use it in GitHub Desktop.
Copies charts into LES Saab 340A at X-Plane. Charts from 01 to 05 are departure's charts. Charts from 06 to 10 are destination's charts. Custom patterns are stored into chart_list.txt. Example chart_list.txt is attached also.
01 7-3-1
02 1-1-1
03 4-2-1
04 4-2-2
05 9-0-0
06 5-[13]-1
07 5-3-2
08 6-1-1
09 1-1-1
10 7-3-1
Param(
$xplane_dir = ".",
$chart_list = ( Get-ChildItem -Recurse -Path "$($xplane_dir)\Aircraft" -Filter "chart_list.txt" | Select-Object -First 1 ),
[Parameter(Mandatory=$true)]
$depICAO,
[Parameter(Mandatory=$true)]
$dstICAO,
$charts_dir = "$($env:USERPROFILE)\OneDrive\Charts"
)
$chart_list |
Get-Content |
Select-Object @{ n='Array'; e={ $_.Split(" ") } } |
Select-Object @{ n='Index'; e={ [int] $_.Array[0] } }, @{n='Page'; e={ $_.Array[1]}} |
Select-Object Index, Page, @{ n='ICAO'; e={ if ($_.Index -le 5) { $depICAO } else { $dstICAO } } } |
Select-Object Index, Page, ICAO,
@{n='Png'; e={ Get-ChildItem -Path "$($charts_dir)\$($_.ICAO)" | ? Name -Like "*$($_.Page)*" | Select-Object -First 1 } } |
Select-Object Page, ICAO, Png,
@{n='Index'; e={ $_.Index.ToString().PadLeft(2,"0") } } |
% { $_.Png | Copy-Item -Destination "$($chart_list.Directory)\chart_$($_.Index).png" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment