C
C#Bino

❔ Avisynth script maker thing

Im trying to make a script that creates AVS files for every file in a Directory based on a template. Here’s what i have so far: string[] lines = Directory.GetFiles(@"H:\Cartoons, Anime und co\Jim der Regenwurm"); string text = File.ReadAllText("Template.avs"); foreach(string name in lines) text = text.Replace("[CLIP]", (name)); File.WriteAllText ("JimNew.avs", text); I can’t figure out how to make it write every path to a new file that it creates automatically. I tried using foreach but it didn’t work.
A
Angius397d ago
Well, using foreach was a good call You simply need to include that File.WriteAllText() inside of the loop
foreach (var thing in things)
Foo();
Bar();
foreach (var thing in things)
Foo();
Bar();
is the equivalent to
foreach (var thing in things)
{
Foo();
}
Bar();
foreach (var thing in things)
{
Foo();
}
Bar();
not
foreach (var thing in things)
{
Foo();
Bar();
}
foreach (var thing in things)
{
Foo();
Bar();
}
Protip: always use braces and remember that whitespace in C# doesn't define the scope, it's not Python
B
Bino396d ago
Thx for the help but i actually got my buddy to help, he made a nice thing
var templatePath = "Jim.avs";
var inputDirectory = @"H:\Cartoons, Anime und co\Jim der Regenwurm";
var outputDirectory = @"C:\Temp";
var templateText = File.ReadAllText(templatePath);
foreach (var filePath in Directory.GetFiles(inputDirectory))
{
var fileName = Path.GetFileNameWithoutExtension(filePath);
var newFileText = templateText.Replace("[CLIP]", filePath);
var outputFilePath = Path.Combine(outputDirectory, $"{fileName}.avs");
File.WriteAllText(outputFilePath, newFileText);
}
var templatePath = "Jim.avs";
var inputDirectory = @"H:\Cartoons, Anime und co\Jim der Regenwurm";
var outputDirectory = @"C:\Temp";
var templateText = File.ReadAllText(templatePath);
foreach (var filePath in Directory.GetFiles(inputDirectory))
{
var fileName = Path.GetFileNameWithoutExtension(filePath);
var newFileText = templateText.Replace("[CLIP]", filePath);
var outputFilePath = Path.Combine(outputDirectory, $"{fileName}.avs");
File.WriteAllText(outputFilePath, newFileText);
}
A
Anton396d ago
use EnumerateFiles instead of GetFiles
B
Bino396d ago
var finalFile = Path.Combine(outputPath, $"{fileName}.mkv"); Console.WriteLine("Merging the files"); ExecuteCmd(ffmpegPath, @$"-i ""{videoFile}"" -i ""{audioFile}"" -c copy ""{fileName}"""); void ExecuteCmd(string ffmpegPath, string v) { throw new NotImplementedException(); } trying to mux files using ffmpeg gives me an error saying not implemented var ffmpegPath = @"C:\Program Files\FFmpeg\ffmpeg.exe"; var outputPath = @"c:\Temp"; var inputPath = @"C:\EarthwormJimCartoonDVD1\VIDEO_TS\audio"; var audioFile = Path.Combine(inputPath, "$.ac3"); var videoFile = Path.Combine(inputPath, "$.mkv"); var fileName = Path.GetFileNameWithoutExtension(inputPath); var finalFile = Path.Combine(outputPath, $"{fileName}.mkv"); Console.WriteLine("Merging the files"); ExecuteCmd(ffmpegPath, @$"-i ""{videoFile}"" -i ""{audioFile}"" -c copy ""{fileName}"""); void ExecuteCmd(string cmd, string arguments) { var processInfo = new ProcessStartInfo { FileName = cmd, Arguments = arguments, CreateNoWindow = true, UseShellExecute = false }; var process = Process.Start(processInfo); process?.WaitForExit(); } full code rn
A
Anton396d ago
Use the library CliWrap
A
Anton396d ago
GitHub
GitHub - Tyrrrz/CliWrap: Library for running command-line processes
Library for running command-line processes. Contribute to Tyrrrz/CliWrap development by creating an account on GitHub.
A
Anton396d ago
I mean, it's fine without it, but this thing is more convenient and can escape arguments
B
Bino396d ago
Will give that a go Thx
A
Accord395d ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
B
Bino378d ago
Never got around to trying
A
Accord375d ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ How to work with Hwnd in c#I want to open programs using Process.Start but all those programs have empty MainWindowHandle and M❔ VS For Mac Code CoverageHas anyone figured out how to show which lines are covered after running unit tests in VS For Mac?✅ Run code in main thread after Task.Run completed?Hello, I have a long running void function that I execute in a separate thread by calling `Task.Run(❔ methodHello, If I create a method, does the method know about things in the Main method? Or am I supposed ❔ Project structure1. In my Solution there should be only 1 Project right? Unless its a big App 2. I started using fo❔ how to use EF6 in library with no dependancy injection and no startup.csI used EF core power tools to generate DB Context and reverse engineer the models. now I get an erro❔ HeadFirst Design PatternSo I started with this Book today. First problem starts with the Duck Project: and when he tests h✅ EqualityComparerHello, anyone know of this code work ? --> `EqualityComparer<ICollection<myclass>> .Default.Equals❔ error attaching script (unity)this error appears when trying to attach the script, does anyone know how to solve it?❔ i have an app that runs well on my pc but not on other pcsi have an app that runs well on my pc but on when i zip it and bring it to another pc the ui is all yield???```cs public IEnumerable<int> A() { for (int i = 0; i <= 10; i += 2) yield return i; } C# Data Table issuehttps://pastebin.com/DSHwSh0M based on this program, I need to set the values of the `Old PS A11Y S❔ Microsoft Graph SDK - Serializing objectsHello, I am currently working with Microsoft Graph API to work with the Planner. My goal is to backu❔ XML deserialise different types into a single listI'm using the build in XML serialisation library (unless it's with .NET framework?), and I current h❔ Access things from different scene in UnityI have a Class Selector scene that has a Class Selector Script component (MonoBehaviour) attached to❔ C# how do I write an If-statement to handle a button?Hi, I wanted some assistance with writing a If-statement that filters out the zones section in my ap❔ Magnetic Links for application?Hey, does someone have an article/tutorial/explanation how I can develop magnetic links for my appli❔ Show values from a list in a datagridview getting source from bindingsourceHello! I have the following problem: I am currently developing a winforms app with a datagridview th❔ Render email content .NET 7 (razor)I have to reinplement email content rendering, because currently its not looking really good, especi❔ GetAxis wont workpublic class Driver : MonoBehaviour { // Start is called before the first frame update const