-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
229 lines (224 loc) · 11.1 KB
/
Copy pathProgram.cs
File metadata and controls
229 lines (224 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Xml;
using static System.Net.Mime.MediaTypeNames;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct OpenFileName
{
public int lStructSize;
public IntPtr hwndOwner;
public IntPtr hInstance;
public string lpstrFilter;
public string lpstrCustomFilter;
public int nMaxCustFilter;
public int nFilterIndex;
public string lpstrFile;
public int nMaxFile;
public string lpstrFileTitle;
public int nMaxFileTitle;
public string lpstrInitialDir;
public string lpstrTitle;
public int Flags;
public short nFileOffset;
public short nFileExtension;
public string lpstrDefExt;
public IntPtr lCustData;
public IntPtr lpfnHook;
public string lpTemplateName;
public IntPtr pvReserved;
public int dwReserved;
public int flagsEx;
}
class OutlastWemConverter
{
[DllImport("comdlg32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern bool GetOpenFileName(ref OpenFileName ofn);
private static string ShowDialog()
{
var ofn = new OpenFileName();
ofn.lStructSize = Marshal.SizeOf(ofn);
ofn.lpstrFilter = "SoundbanksInfo.xml\0SoundbanksInfo.xml\0";
ofn.lpstrFile = new string(new char[256]);
ofn.nMaxFile = ofn.lpstrFile.Length;
ofn.lpstrFileTitle = new string(new char[64]);
ofn.nMaxFileTitle = ofn.lpstrFileTitle.Length;
ofn.lpstrTitle = "Open SoundBanksInfo...";
if (GetOpenFileName(ref ofn))
return ofn.lpstrFile;
return string.Empty;
}
static void Main(string[] args)
{
string wemsdir = AppDomain.CurrentDomain.BaseDirectory + "/wems";
string wavsdir = AppDomain.CurrentDomain.BaseDirectory + "/wavs";
if (!Directory.Exists(wemsdir)) Directory.CreateDirectory(wemsdir);
if (!Directory.Exists(wavsdir)) Directory.CreateDirectory(wavsdir);
Console.WriteLine("Press E -> Convert Wem ShortName to ID (Example: VO_02_SE680_0532_TRAG_300532.wem to 463274111.wem)\nPress R -> Convert Wem ID to ShortName (Example: 463274111.wem to VO_02_SE680_0532_TRAG_300532.wem)\nPress T -> Convert Wem ShortName_Hash to ShortName (Example: VO_02_SE860_0645_TRAG_300645_583901A4.wem to VO_02_SE860_0645_TRAG_300645.wem)\nPress D -> Convert Wav ShortName to ID (Example: VO_02_SE680_0532_TRAG_300532.wav to 463274111.wav)\nPress F -> Convert Wav ID to ShortName (Example: 463274111.wav to VO_02_SE680_0532_TRAG_300532.wav)");
ConsoleKey Key = Console.ReadKey().Key;
if (Key == ConsoleKey.E)
{
Console.Clear();
XmlDocument doc = new XmlDocument();
doc.Load(ShowDialog());
Console.WriteLine("\nScanning!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
foreach (XmlNode node in doc.DocumentElement)
{
string name = node.LocalName;
if (name == "SoundBanks")
{
foreach (XmlNode curbank in node.ChildNodes) // All Soundbanks
{
foreach (XmlNode curbanksection in curbank.ChildNodes) // Only IncludedFullFiles Section
{
if (curbanksection.LocalName == "IncludedFullFiles")
{
foreach (XmlNode curbankfile in curbanksection.ChildNodes) // All Memory Files in soundbank
{
if (File.Exists(wemsdir + "/" + curbankfile.ChildNodes[0].InnerText.Replace(".wav", ".wem")))
{
string sourcewem = wemsdir + "/" + curbankfile.ChildNodes[0].InnerText; // ShortName
string outwem = wemsdir + "/" + curbankfile.Attributes[0].Value + ".wem"; // ID
Console.WriteLine(sourcewem.Replace(".wav", ".wem").Replace(wemsdir + "/", "") + " -> " + outwem.Replace(wemsdir + "/", ""));
File.Move(sourcewem.Replace(".wav", ".wem"), outwem); // Rename ShortName to ID
}
}
}
}
}
}
}
Console.WriteLine("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nCompleted!\nPress any key to exit...");
Console.ReadKey();
return;
}
else if (Key == ConsoleKey.R)
{
Console.Clear();
XmlDocument doc = new XmlDocument();
doc.Load(ShowDialog());
Console.WriteLine("\nScanning!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
foreach (XmlNode node in doc.DocumentElement)
{
string name = node.LocalName;
if (name == "SoundBanks")
{
foreach (XmlNode curbank in node.ChildNodes) // All Soundbanks
{
foreach (XmlNode curbanksection in curbank.ChildNodes) // Only IncludedFullFiles Section
{
if (curbanksection.LocalName == "IncludedFullFiles")
{
foreach (XmlNode curbankfile in curbanksection.ChildNodes) // All Memory Files in soundbank
{
if (File.Exists(wemsdir + "/" + curbankfile.Attributes[0].Value + ".wem"))
{
string sourcewem = wemsdir + "/" + curbankfile.Attributes[0].Value + ".wem"; // Memory File ID
string outwem = wemsdir + "/" + curbankfile.ChildNodes[0].InnerText.Replace(".wav", ".wem"); // Memory File ShortName
Console.WriteLine(sourcewem.Replace(wemsdir + "/", "") + " -> " + outwem.Replace(wemsdir + "/", ""));
File.Move(sourcewem, outwem); // Rename ID to ShortName
}
}
}
}
}
}
}
Console.WriteLine("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nCompleted!\nPress any key to exit...");
Console.ReadKey();
return;
}
else if (Key == ConsoleKey.D)
{
Console.Clear();
XmlDocument doc = new XmlDocument();
doc.Load(ShowDialog());
Console.WriteLine("\nScanning!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
foreach (XmlNode node in doc.DocumentElement)
{
string name = node.LocalName;
if (name == "SoundBanks")
{
foreach (XmlNode curbank in node.ChildNodes) // All Soundbanks
{
foreach (XmlNode curbanksection in curbank.ChildNodes) // Only IncludedFullFiles Section
{
if (curbanksection.LocalName == "IncludedFullFiles")
{
foreach (XmlNode curbankfile in curbanksection.ChildNodes) // All Memory Files in soundbank
{
if (File.Exists(wavsdir + "/" + curbankfile.ChildNodes[0].InnerText))
{
string sourcewem = wavsdir + "/" + curbankfile.ChildNodes[0].InnerText; // ShortName
string outwem = wavsdir + "/" + curbankfile.Attributes[0].Value + ".wav"; // ID
Console.WriteLine(sourcewem.Replace(wavsdir + "/", "") + " -> " + outwem.Replace(wavsdir + "/", ""));
File.Move(sourcewem, outwem); // Rename ShortName to ID
}
}
}
}
}
}
}
Console.WriteLine("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nCompleted!\nPress any key to exit...");
Console.ReadKey();
return;
}
else if (Key == ConsoleKey.F)
{
Console.Clear();
XmlDocument doc = new XmlDocument();
doc.Load(ShowDialog());
Console.WriteLine("\nScanning!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
foreach (XmlNode node in doc.DocumentElement)
{
string name = node.LocalName;
if (name == "SoundBanks")
{
foreach (XmlNode curbank in node.ChildNodes) // All Soundbanks
{
foreach (XmlNode curbanksection in curbank.ChildNodes) // Only IncludedFullFiles Section
{
if (curbanksection.LocalName == "IncludedFullFiles")
{
foreach (XmlNode curbankfile in curbanksection.ChildNodes) // All Memory Files in soundbank
{
if (File.Exists(wavsdir + "/" + curbankfile.Attributes[0].Value + ".wav"))
{
string sourcewem = wavsdir + "/" + curbankfile.Attributes[0].Value + ".wav"; // Memory File ID
string outwem = wavsdir + "/" + curbankfile.ChildNodes[0].InnerText; // Memory File ShortName
Console.WriteLine(sourcewem.Replace(wavsdir + "/", "") + " -> " + outwem.Replace(wavsdir + "/", ""));
File.Move(sourcewem, outwem); // Rename ID to ShortName
}
}
}
}
}
}
}
Console.WriteLine("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nCompleted!\nPress any key to exit...");
Console.ReadKey();
return;
}
else if (Key == ConsoleKey.T)
{
Console.Clear();
Console.WriteLine("\nScanning!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
foreach (string file in Directory.EnumerateFiles(wemsdir, "*.wem", SearchOption.AllDirectories)) // All .wem Files
{
if (File.Exists(file))
{
string sourcewem = file;
string outwem = file.Substring(0, file.LastIndexOf("_")) + ".wem";
Console.WriteLine(sourcewem.Replace(wemsdir + "\\", "") + " -> " + outwem.Replace(wemsdir + "\\", ""));
File.Move(sourcewem, outwem); // Rename ID to ShortName
}
}
Console.WriteLine("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nCompleted!\nPress any key to exit...");
Console.ReadKey();
return;
}
else return;
}
}