Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
122 lines (113 loc) · 5.15 KB
/
Copy pathProgram.cs
File metadata and controls
122 lines (113 loc) · 5.15 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.IO;
// This App sorts my downloads folder by file type
namespace DownloadsManager
{
class Program
{
static string DOWNLOADS_FOLDER = "C:\\Users\\" + Environment.UserName +"\\Downloads";
static string PDF_FOLDER = DOWNLOADS_FOLDER + "\\PDFs";
static string PICTURES_FOLDER = DOWNLOADS_FOLDER + "\\Pics";
static string ISO_FOLDER = DOWNLOADS_FOLDER + "\\ISOs";
static string EXE_FOLDER = DOWNLOADS_FOLDER + "\\EXEs";
static string ZIP_FOLDER = DOWNLOADS_FOLDER + "\\Archives";
static string VIDEO_FOLDER = DOWNLOADS_FOLDER + "\\Videos";
static string AUDIO_FOLDER = DOWNLOADS_FOLDER + "\\Music";
static string DOCUMENTS_FOLDER = DOWNLOADS_FOLDER + "\\Documents";
static string FONTS_FOLDER = DOWNLOADS_FOLDER + "\\Fonts";
/**
* Checks to see whether the necessary folders are present
**/
static void Init()
{
// Make sure the directory exists
// If it doesn't exist, the user probably has a custom downloads folder, so exit the program
if (!Directory.Exists(DOWNLOADS_FOLDER))
Environment.Exit(0);
// Move the current process into the downloads folder
Directory.SetCurrentDirectory(DOWNLOADS_FOLDER);
// Each of these checks to see if the folder we're moving things to exists
// If it doesn't exist it'll create the folder
Directory.CreateDirectory(PDF_FOLDER);
Directory.CreateDirectory(PICTURES_FOLDER);
Directory.CreateDirectory(ISO_FOLDER);
Directory.CreateDirectory(EXE_FOLDER);
Directory.CreateDirectory(ZIP_FOLDER);
Directory.CreateDirectory(VIDEO_FOLDER);
Directory.CreateDirectory(DOCUMENTS_FOLDER);
Directory.CreateDirectory(AUDIO_FOLDER);
Directory.CreateDirectory(FONTS_FOLDER);
}
static void MoveFile(string dest_folder, string extention)
{
var files = Directory.EnumerateFiles(DOWNLOADS_FOLDER, extention);
foreach (var currentFile in files)
{
string fileName = currentFile.Substring(DOWNLOADS_FOLDER.Length + 1);
Directory.Move(sourceDirName: currentFile, destDirName: Path.Combine(path1: dest_folder, path2: fileName));
}
}
static void Main(string[] args)
{
Program.Init();
// PDFs
Program.MoveFile(PDF_FOLDER, "*.pdf");
// Images
Program.MoveFile(PICTURES_FOLDER, "*.png");
Program.MoveFile(PICTURES_FOLDER, "*.jpeg");
Program.MoveFile(PICTURES_FOLDER, "*.jpg");
Program.MoveFile(PICTURES_FOLDER, "*.gif");
Program.MoveFile(PICTURES_FOLDER, "*.bmp");
Program.MoveFile(PICTURES_FOLDER, "*.tiff");
Program.MoveFile(PICTURES_FOLDER, "*.raw");
Program.MoveFile(PICTURES_FOLDER, "*.svg");
Program.MoveFile(PICTURES_FOLDER, "*.ico");
Program.MoveFile(PICTURES_FOLDER, "*.jfif");
// ISOs
Program.MoveFile(ISO_FOLDER, "*.iso");
// Executables
Program.MoveFile(EXE_FOLDER, "*.exe");
Program.MoveFile(EXE_FOLDER, "*.msi");
Program.MoveFile(EXE_FOLDER, "*.bat");
// Archives
Program.MoveFile(ZIP_FOLDER, "*.zip");
Program.MoveFile(ZIP_FOLDER, "*.tar.gz");
Program.MoveFile(ZIP_FOLDER, "*.pkg");
Program.MoveFile(ZIP_FOLDER, "*.tar");
Program.MoveFile(ZIP_FOLDER, "*.rar");
Program.MoveFile(ZIP_FOLDER, "*.7z");
// Audio
Program.MoveFile(AUDIO_FOLDER, "*.mp3");
Program.MoveFile(AUDIO_FOLDER, "*.wav");
Program.MoveFile(AUDIO_FOLDER, "*.wma");
Program.MoveFile(AUDIO_FOLDER, "*.ogg");
// Videos
Program.MoveFile(VIDEO_FOLDER, "*.mp4");
Program.MoveFile(VIDEO_FOLDER, "*.mkv");
Program.MoveFile(VIDEO_FOLDER, "*.mov");
Program.MoveFile(VIDEO_FOLDER, "*.wmv");
Program.MoveFile(VIDEO_FOLDER, "*.webm");
Program.MoveFile(VIDEO_FOLDER, "*.avi");
// Documents
Program.MoveFile(DOCUMENTS_FOLDER, "*.txt");
Program.MoveFile(DOCUMENTS_FOLDER, "*.docx");
Program.MoveFile(DOCUMENTS_FOLDER, "*.doc");
Program.MoveFile(DOCUMENTS_FOLDER, "*.ppt");
Program.MoveFile(DOCUMENTS_FOLDER, "*.pptx");
Program.MoveFile(DOCUMENTS_FOLDER, "*.cfg");
Program.MoveFile(DOCUMENTS_FOLDER, "*.config");
Program.MoveFile(DOCUMENTS_FOLDER, "*.xls");
Program.MoveFile(DOCUMENTS_FOLDER, "*.xlsx");
Program.MoveFile(DOCUMENTS_FOLDER, "*.csv");
// Fonts
Program.MoveFile(FONTS_FOLDER, "*.ttf");
Program.MoveFile(FONTS_FOLDER, "*.otf");
Program.MoveFile(FONTS_FOLDER, "*.chr");
}
}
}