Skip to content

Instantly share code, notes, and snippets.

@XPlantefeve
Created January 8, 2016 12:03
Show Gist options
  • Select an option

  • Save XPlantefeve/e8fafd6b8d1163ebff27 to your computer and use it in GitHub Desktop.

Select an option

Save XPlantefeve/e8fafd6b8d1163ebff27 to your computer and use it in GitHub Desktop.
New-Cue
<#
.Synopsis
Short description
.DESCRIPTION
Long description
.EXAMPLE
Example of how to use this cmdlet
.EXAMPLE
Another example of how to use this cmdlet
#>
function New-Cue
{
[CmdletBinding()]
[OutputType([int])]
Param
(
# Param1 help description
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[string[]]$ChapterFile,
[string]$Genre,
[string]$Date,
[string]$Performer,
[string]$Title,
[string]$AudioFile,
[string]$Format
)
Begin
{
if ($Format -and ! $AudioFile) { $AudioFile = "$((gi $ChapterFile).BaseName).$Format" }
if ($AudioFile -and ! $Format) { $Format = (gi $AudioFile).Extension }
}
Process
{
foreach ( $file in $ChapterFile ) {
"REM GENRE ""$Genre"""
"REM DATE ""$Date"""
"PERFORMER ""$Performer"""
"TITLE ""$Title"""
"FILE ""$AudioFile"" $($Format.ToUpper())"
foreach ( $line in (gc $file) ) {
if ( $line -match 'CHAPTER([0-9]*)=(.*)' ) {
" TRACK $($matches[1]) AUDIO"
" TITLE """""
" PERFORMER ""$Performer"""
" INDEX $($matches[1]) $($matches[2])"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment