diff --git a/.profile b/.profile new file mode 100644 index 0000000..81f7cb8 --- /dev/null +++ b/.profile @@ -0,0 +1,36 @@ +# Aliases +# set-alias lyx "C:\Program Files (x86)\LyX 2.3\bin\LyX.exe" +set-alias edge "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" +# set-alias curl "C:\ProgramData\chocolatey\bin\curl.exe" +set-alias vlc "C:\Program Files\VideoLAN\VLC\vlc.exe" +# set-alias py38 "E:\Languages\Python38-64\python.exe" +set-alias firefox "C:\Program Files\Mozilla Firefox\firefox.exe" +# set-alias pm "F:\Programs\Workstations\FL Studio 20.8.1\System\Tools\Plugin Manager\PluginManager.exe" +set-alias chrome "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" +set-alias -option AllScope cls "c:/shellpower/cls.ps1" +# set-alias gw "ghostwriter.exe" +set-alias envars "SystemPropertiesAdvanced.exe" +# set-alias sublime "E:\IDEs\Sublime Text 3\sublime_text.exe" +# set-alias brython brython-cli +# set-alias ptp ptpython +# set-alias sumatra "C:\Program Files\SumatraPDF\SumatraPDF.exe" +set-alias c set-clipboard +set-alias p get-clipboard +set-alias editor (where.exe hx) +# set-alias make "C:\msys64\usr\bin\make.exe" +set-alias s select +set-alias touch "C:\Program Files\Git\usr\bin\touch.exe" +set-alias grep "C:\Program Files\Git\usr\bin\grep.exe" +set-alias gbash "C:\Program Files\Git\git-bash.exe" +# Variables +# $startup = "C:\Users\Kenneth\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" +# $ytdls = "f:/ytdls" +$scripts = "c:/shellpower" +# $mdn = "E:\gitting\gitclone\clones\mdn\content\files\en-us" +# $samples = join-path $ytdls "samples" +# $filth = "e:/projects/web/tilde/eli2and40-tilde_club/organized" +$EDITOR=(where.exe hx) +if ($PWD -eq "C:\Windows\System32") { + cd ~ +} +# clear diff --git a/alert.ps1 b/alert.ps1 index 6f501e3..e907ea8 100644 --- a/alert.ps1 +++ b/alert.ps1 @@ -1,2 +1,3 @@ -$n = if ($args.length) {$args[0] - 1} else {get-random 12} +$n = if ($args.length) {$args[0] - 1} else {(get-random 12)+1} +echo $n foreach ($i in (0..$n)) {play (get-random)} diff --git a/basename.ps1 b/basename.ps1 new file mode 100644 index 0000000..8dd8b84 --- /dev/null +++ b/basename.ps1 @@ -0,0 +1,3 @@ +foreach ($arg in $args) { + split-path -Path $arg -Leaf +} diff --git a/beep.ps1 b/beep.ps1 new file mode 100644 index 0000000..9eaba60 --- /dev/null +++ b/beep.ps1 @@ -0,0 +1,6 @@ +param( + [double]$freq = 440, + [double]$len = 300 +) + +[console]::beep($freq, $len) diff --git a/deploy.ps1 b/deploy.ps1 new file mode 100644 index 0000000..60d8cff --- /dev/null +++ b/deploy.ps1 @@ -0,0 +1,32 @@ +function goBack { + if ($startingDir) { + cd $startingDir + } +} + +if ((split-path -Path $pwd -Leaf).ToLower() -ne "shellpower") { + if ($scripts) { + $startingDir=$pwd + cd $scripts + } else { + echo "not in shellpower and cannot find it" + exit 1 + } +} + +if ($profile) { + if (test-path -Path $profile) { + echo '$profile already exists, not sure what to do (replace or add a source/.).' + goBack + exit 1 + } + if (!(test-path -Path .profile)) { + echo 'cannot find .profile to source to $profile' + goBack + exit 1 + } + # cat .profile > $profile + New-Item -ItemType HardLink -Path "$profile" -Target "$(join-path $pwd .profile)" > $null && echo 'hard linked $profile' +} + +goBack diff --git a/isfile.ps1 b/isfile.ps1 index 9781ab1..12c361a 100644 --- a/isfile.ps1 +++ b/isfile.ps1 @@ -1,9 +1,3 @@ foreach ($arg in $args) { - # $isfile = Test-Path -Path $arg -PathType Leaf Test-Path -Path $arg -PathType Leaf - # echo $isfile - # yield $isfile } - - -# rfile \ No newline at end of file diff --git a/ls.ps1 b/ls.ps1 new file mode 100644 index 0000000..d450804 --- /dev/null +++ b/ls.ps1 @@ -0,0 +1,36 @@ + +# function ls { +# if ($args.length -gt 1) { +# if (isdir $args[0]) { +# for ($i=1; $i -lt $args.length; $i++) { +# get-childitem -name $args[0] $args[$i] +# } +# } else{ +# foreach ($arg in $args) { +# get-childitem -name $arg +# } +# } +# } else { +# get-childitem -name $args[0] +# } +# } + +# ls $args + +function ls { + if ($args.length -gt 1) { + if (isdir $args[0]) { + for ($i=1; $i -lt $args.length; $i++) { + get-childitem -name $args[0] $args[$i] + } + } else{ + foreach ($arg in $args) { + get-childitem -name $arg + } + } + } else { + get-childitem -name $args[0] + } +} + +ls $args diff --git a/mkimagelist.ps1 b/mkimagelist.ps1 new file mode 100644 index 0000000..4271e65 --- /dev/null +++ b/mkimagelist.ps1 @@ -0,0 +1,42 @@ +param ( + [string[]]$Paths +) + +# Define a list of image file extensions to check for (in lowercase) +$imageExtensions = @("jpg", "jpeg", "png", "gif", "bmp", "tiff") + +# Initialize an array to hold image paths +$imageList = @() + +# Iterate through each path provided as an argument +foreach ($path in $Paths) { + # Check if the path is a directory + if (Test-Path $path -PathType Container) { + # Get all files in the directory and check their extensions + $files = Get-ChildItem -Path $path -File -Recurse + foreach ($file in $files) { + # Get the file extension and convert it to lowercase + $extension = $file.Extension.TrimStart('.').ToLower() + if ($imageExtensions -contains $extension) { + $imageList += (Resolve-Path $file.FullName) + } + } + } + # Check if the path is a file and an image + elseif (Test-Path $path -PathType Leaf) { + # Get the file extension and convert it to lowercase + $extension = $path.Substring($path.LastIndexOf('.') + 1).ToLower() + if ($imageExtensions -contains $extension) { + $imageList += (Resolve-Path $path) + } + } +} + +# Create the image_list.txt file in the current working directory +$imageListPath = Join-Path -Path (Get-Location) -ChildPath "image_list.txt" + +# Write the image paths to the file +$imageList | ForEach-Object { "file '$($_)'" } | Set-Content -Path $imageListPath -Encoding UTF8 + +# Inform the user about the created file +Write-Host "Image list created at: $imageListPath" diff --git a/mkimagevid.ps1 b/mkimagevid.ps1 new file mode 100644 index 0000000..c037b3f --- /dev/null +++ b/mkimagevid.ps1 @@ -0,0 +1 @@ +ffmpeg -r 0.1 -f concat -safe 0 -i image_list.txt -c:v libx264 -pix_fmt yuv420p out.mp4 diff --git a/mkvid.ps1 b/mkvid.ps1 new file mode 100644 index 0000000..4af8628 --- /dev/null +++ b/mkvid.ps1 @@ -0,0 +1,8 @@ +image = $args[0] +audio = $args[1] +ffmpeg -loop 1 -i $image -i $audio -c:v libx264 -tune stillimage -c:a copy -b:a 192k -pix_fmt yuv420p -shortest out.mp4 + +# https://duckduckgo.com/?q=ffmpeg+combine+photo+and+audio&t=ffab&ia=web&iax=qa | ffmpeg combine photo and audio at DuckDuckGo +# https://www.bannerbear.com/blog/how-to-create-a-slideshow-from-images-with-ffmpeg/ | How to Create a Slideshow from Images with FFmpeg - Bannerbear +# https://ffmpeg.org/ffmpeg.html | ffmpeg Documentation +# https://duckduckgo.com/?t=ffab&q=high+level+mp4+library&ia=web | high level mp4 library at DuckDuckGo diff --git a/new.ps1 b/new.ps1 index 32e2859..465dbaf 100644 --- a/new.ps1 +++ b/new.ps1 @@ -6,17 +6,30 @@ $help = 'Create new powershell scripts $scripts/name2.ps1 ... $scripts/nameN.ps1 - And then open each file with the system default + And then open each file with the "editor" command defined in $profile ' - + + +$pths=@((join-path $scripts "readme.md")) + if ($args.length) { foreach ($arg in $args) { $pth = join-path $scripts $arg $pth += ($pth.endswith(".ps1")) ? "" : ".ps1" touch $pth - editor (join-path $scripts "readme.md") - editor $pth + $pths += $pth } } else { echo $help } + +# echo $pths + +editor ($pths) + +# clean up +foreach ($file in (dir $scripts)) { + if (!$file.length) { + rm $file + } +} diff --git a/open.ps1 b/open.ps1 new file mode 100644 index 0000000..09060b1 --- /dev/null +++ b/open.ps1 @@ -0,0 +1 @@ +invoke-item $args[0] diff --git a/play.ps1 b/play.ps1 index fb0ffa4..f422523 100644 --- a/play.ps1 +++ b/play.ps1 @@ -1,22 +1,17 @@ -# $root = 440 -# $octave = 5 -# $length = 300 # milisecs +$root = 440 +$octave = 5 +$length = 300 # milisecs -param( - [double]$root = 440, - [double]$octave = 11, - [double]$length = 300 -) foreach ($i in $args) { # if (($i -is [int32]) -or ($i -is [int64]) -or ($i -is [double])) { if (($i -is [int32]) -or ($i -is [int64]) -or ($i -is [double])) { # $freq = $root + (($root / $octave) * ($i % $octave)) $freq = $root / $octave - $freq + # $freq $freq *= $i % $octave - $freq + # $freq $freq += $root - $freq + # $freq [console]::beep($freq, $length) } elseif ($i -is [array]) { foreach ($j in $i) { @@ -25,4 +20,3 @@ foreach ($i in $args) { } } } -$args \ No newline at end of file diff --git a/readme.md b/readme.md index 71e976c..331cd81 100644 --- a/readme.md +++ b/readme.md @@ -6,7 +6,7 @@ A collection of powershell scripts to help aid and play flows [_**how**_](#usage) _**why**_ -*Stubby little fingers grow weary of tired analogies* +*Stubby little fingers grow weary of repeaded command sequences* ### Usage This repository holds PowerShell scripts that I created for personal convenience. @@ -25,6 +25,7 @@ You *__will__* have to personalize: - [new](#new) - [profile](#profile) - [ytdls](#ytdls) + - [gitfast](#gitfast) You *__may__* have to personalize: @@ -55,6 +56,13 @@ Echo a line of text comprised by a repetition of your chosen string qwertyqwertyqwerty ``` +##### basename +offers the same functionality as the eponymous bash command +```powershell +> (basename "c:/program files") -eq "program files" +True +``` + ##### blank Echo n blank lines ```powershell @@ -127,6 +135,12 @@ Copy the name of a random item in the current directory to the clipboard ``` - *See Also:* [names](#names) +##### deploy +a set up script for installing the `.profile` +```powershell +> deploy +``` + ##### dls Clears the screen before implementing [cdls](#cdls) ```powershell @@ -325,6 +339,24 @@ Opens the mozilla mdn docs in explorer - assumes you've set a `$mdn` variable +##### mkimagelist +takes file and directory paths and creates a file, named `image_list.txt` with the found images for giving to `ffmpeg` +```powershell +> mkimagelist [path1 [path2 ...]] +``` + +##### mkimagevid +Commands ffmpeg to create a video using the file generated by `mkimagelist`. The resulting file will be called `out.mp4` +```powershell +> mkimagevid +``` + +##### mkvid +Commands `ffmpeg` to create a video using a given image and audio file. The resulting file will be called `out.mp4` +```powershell +> mkvid image/file/path audio/file/path +``` + ##### names run `ls -n` aka `get-childitem -n` and filter for files whose names match arguments ```powershell @@ -388,6 +420,12 @@ Find out precisely where executables on the path are located - *Note:* You will have to append '.ps1' if you are looking for powershell scripts +##### open +Open the given file with the default program +```powershell +> open path/to/file +``` + ##### pcd cd into the directory in your clipboard ```powershell diff --git a/y22.ps1 b/y22.ps1 index a94bbc8..28173fa 100644 --- a/y22.ps1 +++ b/y22.ps1 @@ -4,6 +4,7 @@ for ($i=0; $i -lt $args.length; $i++) { cd $ytdls blank ($i -eq 0 ? 0: 3) ind ($i+1) $args.length - youtube-dl -f 22 $args[$i] + # youtube-dl -f 22 $args[$i] + yt-dlp -f 22 $args[$i] cd $origin } diff --git a/yda.ps1 b/yda.ps1 index 2fde5f0..6d81d6f 100644 --- a/yda.ps1 +++ b/yda.ps1 @@ -6,7 +6,7 @@ foreach ($arg in $args) { $n += 1 cd $destination ind $n $args.length - youtube-dl -x $arg + yt-dlp -x $arg cd $origin '' '' diff --git a/ydl.ps1 b/ydl.ps1 index 1ec54a1..5f9a03e 100644 --- a/ydl.ps1 +++ b/ydl.ps1 @@ -6,7 +6,8 @@ foreach ($link in $args) { $n += 1 cd $destination ind $n $args.length - youtube-dl $link + # youtube-dl $link + yt-dlp $link cd $origin '' ''