Subject:merge multiple files
Posted by: NickD
Date:10/5/2008 5:53:30 AM
Hi, I am looking for a way to merge a file with multiple files I need to create the numbers 1 - 10,000. I have the basic units already recorded and want to script adding them together.. eg. One hundred.wav one.wav two.wav etc/ I would like to know how to merge my One hundred.wav with numbers one - ninety nine.wav ... thanks Nick |
Subject:RE: merge multiple files
Reply by: NickD
Date:10/6/2008 9:29:52 AM
Below is the code I am working with that I modified from a forum post called automating paste to multiple files. right now the script is compiling but doing nothing though it says complete. info on my setup I have 2 folders - folder 1 - includes one file with the audio "one hundred" folder 2 - includes 99 files that are the numbers 1 - 99. MY PC info Vista on MACPRO 2 3ghz duo 6 gb ram Soundforge 9.e Never did scripting successfully before Truthfully, I dont know where to start because I am uncertain what the code calls my source file for copying and what the code calls my destination directory of files. thanks Nick =================== using System; using System.IO; using System.Windows.Forms; using SoundForge; public class EntryPoint { public void Begin(IScriptableApp app) { string strFolder = SfHelpers.ChooseDirectory("Choose a folder to process files from", @"C:\Users\nick\Desktop\sftest\2"); foreach (string strFilename in Directory.GetFiles(strFolder, "*.mp3")) { SfStatus status = ProcessFile(app, strFilename); if (status != SfStatus.Success) { DPF("{0} : {1}", strFilename, status.ToString()); // quit if processing or save failed. break; } } } public bool bEnableProcessingLog = true; public SfStatus ProcessFile(IScriptableApp app, string strFilename) { if (bEnableProcessingLog) DPF("processing {0}", strFilename); ISfFileHost file = app.OpenFile(strFilename, false, true); if (null == file) return SfStatus.Fail; file.WaitForDoneOrCancel(); // paste whatever audio is in the clipboard to the end of the current file. // since DoMenu always operates on the active Data Window, we need to make // sure that the file we want edited is active before using DoMenu(). file.Window.Active = true; file.Window.Cursor = file.Length; app.DoMenu("Edit.Paste", false); // the other way to paste is OverwriteAudio(), but it requires a pasteFrom file.. // file.OverwriteAudio(file.Length, 0, fileToPasteFrom, new SfAudioSelection(fileToPasteFrom)); // wait for processing to complete, and if it succeeds, save the file SfStatus status = file.WaitForDoneOrCancel(); if (status == SfStatus.Success) { file.Save(SaveOptions.PromptIfNoFilename); status = file.WaitForDoneOrCancel(); } file.Close(CloseOptions.DiscardChanges); return status; } public void FromSoundForge(IScriptableApp app) { ForgeApp = app; //execution begins here app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name)); Begin(app); app.SetStatusText(String.Format("Script '{0}' is done.", Script.Name)); } public static IScriptableApp ForgeApp = null; public static void DPF(string sz) { ForgeApp.OutputText(sz); } public static void DPF(string fmt, object o) { ForgeApp.OutputText(String.Format(fmt,o)); } public static void DPF(string fmt, object o, object o2) { ForgeApp.OutputText(String.Format(fmt,o,o2)); } public static void DPF(string fmt, object o, object o2, object o3) { ForgeApp.OutputText(String.Format(fmt,o,o2,o3)); } } //EntryPoint |
Subject:RE: merge multiple files
Reply by: NickD
Date:10/6/2008 9:37:09 AM
fyi When running the script above I get a message that says SCRIPT HAS DISABLED DRAWING and it does not process the script. |
Subject:RE: merge multiple files
Reply by: _TJ
Date:10/7/2008 2:17:49 PM
This script does not have different source and destination, it appends whatever audio is on the clipboard to each MP3 file in the given folder @"C:\Users\nick\Desktop\sftest\2" And then saves the changes back into the original files. This script will appear to do nothing if the folder does not exist, or if it contains no MP3 files, or if there is no audio in the clipboard. You see the message, "Script has disabled drawing" because the script has disabled drawing. This is line of code that does that
If you change the true at the end of this line to false, then drawing will no longer be disabled. If you want this script to save the files to a different destination, you need to change this line
to use the RenderAs() method instead, something like this
When you post code in the forums, you should use the code tag around it to tell the forum not to mess with the formatting. Otherwise the code is very hard to read. |
Subject:RE: merge multiple files
Reply by: NickD
Date:10/8/2008 8:36:09 AM
Thanks TJ I am having some success with this. couple questions.. where can I get a list of these commands the options/switches for them ? I found the app.domenu commands in the SDK... how about the other types ? Tech Questions.. 1. I would like to save the affected files to a new location..... 2. I would like to change the name before saving though... for example the original files 2.wav, 3.wav etc would become 12.wav, 13.wav ..... any way to choose a freetext to add before file save as.. ??? thanks much for your help nick |
Subject:RE: merge multiple files
Reply by: _TJ
Date:10/8/2008 12:55:43 PM
where can I get a list of these commands the options/switches for them ? I found the app.domenu commands in the SDK... how about the other types ? It's all in the SDK documentation. Pay special attention to the methods on ISfFileHost this is were most of the useful stuff is. 1. I would like to save the affected files to a new location..... I would use SfHelpers.ChooseDirectory() to choose the new location, then Path.Combine and String.Format to build the new filenames. any way to choose a freetext to add before file save as.. ??? I don't understand the question. tj |