This repository was archived by the owner on Apr 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSourceCode
More file actions
204 lines (185 loc) · 7.62 KB
/
SourceCode
File metadata and controls
204 lines (185 loc) · 7.62 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
using System;
using System.IO;
using System.IO.Compression;
using System.Threading;
namespace BeatZip
{
class Program
{
static void Main(string[] args)
{
const string defaultSteamDir = @"C:\Program Files (x86)\Steam\steamapps\common\Beat Saber";
string PCVRInstallDir;
string destFolder;
bool historyEnabled = true;
bool beatSageMode = false;
string historyFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"BeatZip\History.txt");
string beatZipData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"BeatZip");
string pathHistoryFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"BeatZip\PathHistory.txt");
string PCVRSongDir;
if (args.Length != 0)
{
for (int i = 0; i < args.Length; i++)
{
switch (args[i].ToLower())
{
case "-disablehistory":
historyEnabled = false;
Console.WriteLine("History disabled!");
Thread.Sleep(1000);
break;
case "disablehistory":
historyEnabled = false;
Console.WriteLine("History disabled!");
Thread.Sleep(1000);
break;
case "-BeatSageMode":
beatSageMode = true;
Console.WriteLine("Beat Sage Mode enabled!");
Thread.Sleep(1000);
break;
case "BeatSageMode":
beatSageMode = true;
Console.WriteLine("Beat Sage Mode enabled!");
Thread.Sleep(1000);
break;
default:
Console.WriteLine(args[i] + " is an unknown argument. Ignoring...");
Thread.Sleep(1000);
break;
}
}
}
if (historyEnabled == true)
{
if (!Directory.Exists(beatZipData))
{
Directory.CreateDirectory(beatZipData);
using Stream ST = File.Create(historyFile);
}
else if (!File.Exists(historyFile))
{
using Stream ST = File.Create(historyFile);
}
else
{
Console.WriteLine("History file detected and enabled!");
Console.WriteLine("To disable history start the application with the -disablehistory argument");
Thread.Sleep(1000);
Console.Clear();
}
if (!File.Exists(pathHistoryFile))
{
using Stream ST = File.Create(pathHistoryFile);
}
}
string[] history = File.ReadAllLines(historyFile);
string[] pathHistory = File.ReadAllLines(pathHistoryFile);
if (!Directory.Exists(defaultSteamDir))
{
if (pathHistory.Length == 0)
{
Console.Write("Enter your PCVR Beat Saber installation directory: ");
PCVRInstallDir = Console.ReadLine();
using StreamWriter sw = File.AppendText(pathHistoryFile);
sw.WriteLine(PCVRInstallDir);
}
else
{
PCVRInstallDir = pathHistory[0];
}
}
else
{
Console.WriteLine("Default Steam installation detected!");
Thread.Sleep(2000);
PCVRInstallDir = defaultSteamDir;
}
if (pathHistory.Length !<= 1)
{
Console.Write("Enter your destination folder (the folder where to put all the zips): ");
destFolder = Console.ReadLine();
using StreamWriter sw = File.AppendText(pathHistoryFile);
sw.WriteLine(destFolder);
}
else
{
destFolder = pathHistory[1];
}
string destFolderOld = destFolder + @"\old";
if (!Directory.Exists(destFolder))
{
Directory.CreateDirectory(destFolder);
Directory.CreateDirectory(destFolderOld);
}
else if (!Directory.Exists(destFolderOld))
{
Directory.CreateDirectory(destFolderOld);
}
if (!beatSageMode)
{
PCVRSongDir = PCVRInstallDir + @"\Beat Saber_Data\CustomLevels";
}
else
{
PCVRSongDir = PCVRInstallDir;
}
string[] subdirs = Directory.GetDirectories(PCVRSongDir);
for (int i = 0; i < subdirs.Length; i++)
{
string currentFileName = Path.GetFileName(Path.TrimEndingDirectorySeparator(subdirs[i])) + ".zip";
Console.WriteLine(currentFileName);
string currentFilePath = destFolder + @"\" + currentFileName;
if (File.Exists(currentFilePath))
{
Console.WriteLine("Already exists! Moving to old {0} out of {1}", i + 1, subdirs.Length);
File.Move(currentFilePath, destFolderOld + @"\" + currentFileName, true);
Console.WriteLine();
Thread.Sleep(5);
continue;
}
else if (File.Exists(destFolderOld + @"\" + currentFileName))
{
Console.WriteLine("Already exists in old! Skipping {0} out of {1}", i + 1, subdirs.Length);
Console.WriteLine();
Thread.Sleep(5);
continue;
}
else if (historyEnabled == true)
{
bool foundInHistory = false;
foreach (string song in history)
{
if (song == currentFileName)
{
Console.WriteLine("Found in history! Skipping {0} out of {1}", i + 1, subdirs.Length);
Console.WriteLine();
foundInHistory = true;
break;
}
}
if (foundInHistory)
{
continue;
}
}
Console.WriteLine("Zipping {0} out of {1}", i + 1, subdirs.Length);
ZipFile.CreateFromDirectory(subdirs[i], destFolder + @"\" + currentFileName);
Console.WriteLine("Zipped succesfully!");
if (historyEnabled == true)
{
using StreamWriter sw = File.AppendText(historyFile);
sw.WriteLine(currentFileName);
}
Console.WriteLine();
}
Thread.Sleep(500);
Console.WriteLine();
Thread.Sleep(500);
Console.WriteLine();
Thread.Sleep(500);
Console.WriteLine("All files zipped succesfully");
Thread.Sleep(10000);
}
}
}