Skip to content

Instantly share code, notes, and snippets.

@Xwilarg
Created July 25, 2023 17:05
Show Gist options
  • Save Xwilarg/e81746c76b967e2564ab1422c872e2aa to your computer and use it in GitHub Desktop.
Save Xwilarg/e81746c76b967e2564ab1422c872e2aa to your computer and use it in GitHub Desktop.
Convert a bunch of file to a specified format
using System.Diagnostics;
Console.WriteLine("What input format do you want?");
string format = Console.ReadLine();
Console.WriteLine("Enter the location of the files");
string path = Console.ReadLine();
void ConvertFolder(string path)
{
foreach (var f in Directory.GetFiles(path))
{
var fi = new FileInfo(f);
var name = Path.GetFileNameWithoutExtension(fi.Name);
Process.Start("ffmpeg", $"-i {f} {path}{Path.DirectorySeparatorChar}{name}.{format}");
}
foreach (var d in Directory.GetDirectories(path))
{
ConvertFolder(d);
}
}
ConvertFolder(path);
@TheIndra55
Copy link

TheIndra55 commented Jul 25, 2023

Get-ChildItem -Recurse -Filter *.mp4 | ForEach-Object { ffmpeg -i $_ "$($_.DirectoryName)/$($_.BaseName).mkv" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment