Add all files
This commit is contained in:
9
.idea/artifacts/copy_images_jar.xml
generated
Normal file
9
.idea/artifacts/copy_images_jar.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<component name="ArtifactManager">
|
||||||
|
<artifact type="jar" name="copy-images:jar">
|
||||||
|
<output-path>$PROJECT_DIR$/out/artifacts/copy_images_jar</output-path>
|
||||||
|
<root id="archive" name="copy-images.jar">
|
||||||
|
<element id="module-output" name="copy-images" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/lib/commons-io-2.6.jar" path-in-jar="/" />
|
||||||
|
</root>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/copy-images.iml" filepath="$PROJECT_DIR$/copy-images.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
12
copy-images.iml
Normal file
12
copy-images.iml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="lib" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
3
src/META-INF/MANIFEST.MF
Normal file
3
src/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Main-Class: Main
|
||||||
|
|
||||||
59
src/Main.java
Normal file
59
src/Main.java
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
import javax.imageio.IIOException;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// Start here...
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
System.out.println("Enter a path: ");
|
||||||
|
String filePath = sc.nextLine();
|
||||||
|
System.out.println("debug mode on? (Y/N)");
|
||||||
|
String debugChoice = sc.nextLine().trim().toLowerCase();
|
||||||
|
boolean debug = debugChoice.equals("y");
|
||||||
|
listDirs(new File(filePath), debug, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void listDirs(File file, boolean debug, String directoryName) {
|
||||||
|
if (file.isFile()) { //stopping condition
|
||||||
|
String name = file.getName().toLowerCase();
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
if (!directoryName.endsWith("/") && !directoryName.isEmpty()) directoryName += "/";
|
||||||
|
// check if image
|
||||||
|
if (name.endsWith(".jpg") || name.endsWith(".png") || name.endsWith(".jpeg") || name.endsWith(".tiff") || name.endsWith(".gif")) {
|
||||||
|
if (debug) System.out.println("checking file " + file.getName());
|
||||||
|
FileUtils.copyFile(file, new File("images/" + directoryName + file.getName()));
|
||||||
|
} else if (name.endsWith(".mp4") || name.endsWith(".wmv") || name.endsWith(".mov") || name.endsWith(".avi")) { //check if video
|
||||||
|
if (debug) System.out.println("checking file " + file.getName());
|
||||||
|
FileUtils.copyFile(file, new File("videos/" + directoryName + file.getName()));
|
||||||
|
} else if (name.endsWith(".mp3") || name.endsWith(".wav")) { //check if audio file
|
||||||
|
if (debug) System.out.println("checking file " + file.getName());
|
||||||
|
FileUtils.copyFile(file, new File("music/" + directoryName + file.getName()));
|
||||||
|
} else if (name.endsWith(".doc") || name.endsWith(".docx") || name.endsWith(".rtf")) {
|
||||||
|
if (debug) System.out.println("checking file " + file.getName());
|
||||||
|
FileUtils.copyFile(file, new File("docs/" + directoryName + file.getName()));
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("something went wrong: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
if (file.listFiles() != null) {
|
||||||
|
if (!directoryName.endsWith("/")) directoryName += "/";
|
||||||
|
for (File file1 : Objects.requireNonNull(file.listFiles())) {
|
||||||
|
listDirs(file1, debug, directoryName + file.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
testdir/images.jpg
Normal file
BIN
testdir/images.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.3 KiB |
0
testdir/test2/img.png
Normal file
0
testdir/test2/img.png
Normal file
0
testdir/test2/test3/img2.png
Normal file
0
testdir/test2/test3/img2.png
Normal file
Reference in New Issue
Block a user