Change -Suffix parameter in Create-Clip.ps1 from optional empty string to required non-empty string with default value "-Clip", removing the hardcoded "-Clip" prefix from target name derivation so suffix is inserted directly before extension (e.g. default behavior unchanged: P01.mp4 -> P01-Clip.mp4, but custom -Suffix "-Shot-1" now makes P01.mp4 -> P01-Shot-1.mp4 instead of P01-Clip-Shot-1.mp4), add ValidateNotNullOrEmpty attribute, update documentation to reflect new default and behavior, and add installation
This commit is contained in:
1 parent
61894433d9
commit
4cc09d6369
4 files changed
+323
-13
No files matched your search
+9
-8
@@ -1,8 +1,8 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Creates a new clipped video file using Clone-Video.ps1, requiring the -Video and -Frames parameters.
|
||||
The filename used for the -Target parameter is automatically derived from the -Video filename, with "-Clip" inserted before the video file extension (e.g., P01.mp4 becomes P01-Clip.mp4).
|
||||
When the video name carries a '.skip' marker before its extension, "-Clip" is inserted before that marker so it stays last (e.g., P01.skip.mp4 becomes P01-Clip.skip.mp4).
|
||||
The filename used for the -Target parameter is automatically derived from the -Video filename, with the -Suffix value (default "-Clip") inserted before the video file extension (e.g., P01.mp4 becomes P01-Clip.mp4).
|
||||
When the video name carries a '.skip' marker before its extension, the suffix is inserted before that marker so it stays last (e.g., P01.skip.mp4 becomes P01-Clip.skip.mp4).
|
||||
Any extra parameters will be pass directly to Clone-Video.ps1, except for parameters -Video, -Frames, -Suffix and -Target.
|
||||
.PARAMETER Video
|
||||
Path to the input video file. Can be absolute or relative to current directory. If the path has no extension, .mp4, .webm and .mkv are tried in turn.
|
||||
@@ -14,8 +14,8 @@
|
||||
- %: Represents the last frame index. Can be used alone or in ranges (e.g., "%", "10-%", "-%")
|
||||
- all: Extract all frames (same as "0-%")
|
||||
.PARAMETER Suffix
|
||||
Optional text appended to the derived -Target name after "-Clip" and before the file extension
|
||||
(e.g. -Suffix "-Shot-1" makes P01.mp4 become P01-Clip-Shot-1.mp4). A '.skip' marker still stays last.
|
||||
Text inserted into the derived -Target name before the file extension. Defaults to "-Clip" and cannot be empty.
|
||||
Example: -Suffix "-Clip-Shot-1" makes P01.mp4 become P01-Clip-Shot-1.mp4. A '.skip' marker still stays last.
|
||||
#>
|
||||
[CmdletBinding(SupportsShouldProcess)]
|
||||
param(
|
||||
@@ -26,7 +26,8 @@ param(
|
||||
[string]$Frames,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$Suffix = '',
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Suffix = '-Clip',
|
||||
|
||||
[Parameter(ValueFromRemainingArguments)]
|
||||
[object[]]$ExtraArgs
|
||||
@@ -50,12 +51,12 @@ if (-not (Test-Path -LiteralPath $videoPath)) {
|
||||
}
|
||||
}
|
||||
|
||||
# Derive the -Target path: insert "-Clip" before the file extension (e.g., P01.mp4 -> P01-Clip.mp4)
|
||||
# Derive the -Target path: insert -Suffix before the file extension (e.g., P01.mp4 -> P01-Clip.mp4)
|
||||
$sourceExt = [System.IO.Path]::GetExtension($videoPath)
|
||||
$sourceBase = [System.IO.Path]::GetFileNameWithoutExtension($videoPath)
|
||||
$sourceDir = [System.IO.Path]::GetDirectoryName($videoPath)
|
||||
|
||||
# A '.skip' marker must stay immediately before the container extension, so "-Clip" is
|
||||
# A '.skip' marker must stay immediately before the container extension, so the suffix is
|
||||
# inserted before it rather than after (e.g., P01.skip.mp4 -> P01-Clip.skip.mp4).
|
||||
# The marker's original casing is preserved.
|
||||
$skipMarker = ''
|
||||
@@ -64,7 +65,7 @@ if ($sourceBase -match '^(.*)(\.skip)$') {
|
||||
$skipMarker = $Matches[2]
|
||||
}
|
||||
|
||||
$targetName = "$sourceBase-Clip$Suffix$skipMarker$sourceExt"
|
||||
$targetName = "$sourceBase$Suffix$skipMarker$sourceExt"
|
||||
$targetPath = if ([string]::IsNullOrEmpty($sourceDir)) { $targetName } else { Join-Path $sourceDir $targetName }
|
||||
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
|
||||
Reference in new issue
Block a user