-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateFolderStructure.java
51 lines (39 loc) · 1.78 KB
/
CreateFolderStructure.java
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
import java.io.*;
import java.util.*;
public class CreateFolderStructure {
public static void main (String[] args) throws IOException {
Scanner input = new Scanner(System.in);
System.out.print("Enter semester number: ");
Integer semesterNumber = input.nextInt();
input.nextLine(); //consume the newline character
String semesterDirectoryName = "SEM" + semesterNumber;
File semesterDirectory = new File(semesterDirectoryName);
if(!semesterDirectory.exists()) {
semesterDirectory.mkdir();
}
System.out.print("Enter how many courses are you taking this semester? (this will result in the number of folders created): ");
Integer numberOfFolders = input.nextInt();
input.nextLine();
System.out.println();
for (int num = 1; num <= numberOfFolders; num++) {
System.out.print("Enter the name for folder " + num + ":");
String userCourseName = input.nextLine();
File courseDirectory = new File(semesterDirectoryName + File.separator + userCourseName);
if(!courseDirectory.exists()) {
courseDirectory.mkdir();
//call method that create directory structure inside each course directory
createSubdirectories(courseDirectory);
}
System.out.println();
}
}
public static void createSubdirectories(File path) {
List<String> subDirectoriesNames = Arrays.asList("Slides", "Labs", "ClassesNotes", "ImportantMaterial");
for(String folderName : subDirectoriesNames) {
File subFolder = new File(path + File.separator + folderName);
if(!subFolder.exists()) {
subFolder.mkdir();
}
}
}
}