diff --git a/README.md b/README.md index 69fd4b5..54ffec2 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ Extracts files from one or multiple folders and moves them to the parent folder. -How to use the extension filter: -Add file extensions into the text field and separate extensions with comma. -If you didn't write anything or whitespaces the program will extract all files. - TODOS: -- improve GUI \ No newline at end of file +- improve GUI +- add file filter \ No newline at end of file diff --git a/releases/GetYourFilesOutThere 0.2.jar b/releases/GetYourFilesOutThere 0.2.jar deleted file mode 100644 index c5aa1cd..0000000 Binary files a/releases/GetYourFilesOutThere 0.2.jar and /dev/null differ diff --git a/releases/GetYourFilesOutThere 0.3.jar b/releases/GetYourFilesOutThere 0.3.jar deleted file mode 100644 index db0800c..0000000 Binary files a/releases/GetYourFilesOutThere 0.3.jar and /dev/null differ diff --git a/src/eu/seelenoede/getyourfilesoutthere/Engine.java b/src/eu/seelenoede/getyourfilesoutthere/Engine.java deleted file mode 100644 index 4371c34..0000000 --- a/src/eu/seelenoede/getyourfilesoutthere/Engine.java +++ /dev/null @@ -1,56 +0,0 @@ -package eu.seelenoede.getyourfilesoutthere; - -import java.io.File; -import java.io.IOException; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; - -public class Engine { - - private SettingsFilter filter; - - public Engine() { - filter = new SettingsFilter(); - } - - /** - * Extract files from the directories - * - * @author Seelenoede - */ - protected void extractFiles(File[] dirs) { - - for(File dir:dirs) { - try { - String parentDir = dir.getCanonicalFile().getParent(); - - File[] files; - if(filter.extensions.size() == 0) - files = dir.listFiles(); - else - files = dir.listFiles(filter); - - for(File file:files) { - Path target = FileSystems.getDefault().getPath(parentDir + "\\" + file.getName()); - - Files.move(file.toPath(), target, StandardCopyOption.REPLACE_EXISTING); - } - } - catch (IOException e) { - e.printStackTrace(); - } - } - } - - protected void setExtensionSettings(String extensionString) { - if(extensionString.equals("")) { - return; - } - String[] extensions = extensionString.split(","); - for(String extension:extensions) { - filter.extensions.add(extension.trim()); - } - } -} diff --git a/src/eu/seelenoede/getyourfilesoutthere/GUI.fxml b/src/eu/seelenoede/getyourfilesoutthere/GUI.fxml deleted file mode 100644 index 8f91c17..0000000 --- a/src/eu/seelenoede/getyourfilesoutthere/GUI.fxml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - -
- -
- - -
diff --git a/src/eu/seelenoede/getyourfilesoutthere/Main.java b/src/eu/seelenoede/getyourfilesoutthere/Main.java deleted file mode 100644 index 62684e3..0000000 --- a/src/eu/seelenoede/getyourfilesoutthere/Main.java +++ /dev/null @@ -1,95 +0,0 @@ -package eu.seelenoede.getyourfilesoutthere; - -import java.io.File; -import java.io.IOException; - -import javax.swing.JFileChooser; - -import javafx.application.Application; -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.scene.control.Label; -import javafx.scene.control.TextField; -import javafx.stage.Stage; - -public class Main extends Application { - - private boolean alreadyRunning; - private File[] dirs; - private Engine engine; - - @FXML Label lblDone; - @FXML TextField textField_dirs; - @FXML TextField textField_extensions; - - @FXML - public void initialize() { - engine = new Engine(); - alreadyRunning = false; - } - - @Override - public void start(Stage primaryStage) throws IOException { - Parent root = FXMLLoader.load(getClass().getResource("GUI.fxml")); - - Scene scene = new Scene(root); - primaryStage.setTitle("Get Your Files Out There"); - primaryStage.setScene(scene); - primaryStage.show(); - } - - public static void main(String[] args) { - launch(args); - } - - @FXML - private void handleBrowseButtonAction(ActionEvent event) { - selectDirs(); - } - - @FXML - private void handleStartButtonAction(ActionEvent event) { - Thread noBlock = new Thread() { - public void run() { - engine.setExtensionSettings(textField_extensions.getText()); - resetElements(); - engine.extractFiles(dirs); - alreadyRunning = false; - lblDone.setVisible(true); - } - }; - if ((!alreadyRunning) & (dirs!=null)) { - noBlock.start(); - alreadyRunning = true; - } - } - - private void resetElements() { - lblDone.setVisible(false); - } - - private void selectDirs() { - if(alreadyRunning){ - return; - } - JFileChooser chooser = new JFileChooser(); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - chooser.setMultiSelectionEnabled(true); - int val = chooser.showOpenDialog(null); - - if (val == JFileChooser.APPROVE_OPTION) { - dirs = chooser.getSelectedFiles(); - String selectedDirs = ""; - for (File dir:dirs) - { - selectedDirs = selectedDirs + "\"" + dir.getAbsolutePath() + "\"; "; - } - textField_dirs.setText(selectedDirs); - } - } - - -} diff --git a/src/eu/seelenoede/getyourfilesoutthere/MainForm.java b/src/eu/seelenoede/getyourfilesoutthere/MainForm.java new file mode 100644 index 0000000..7bdca1c --- /dev/null +++ b/src/eu/seelenoede/getyourfilesoutthere/MainForm.java @@ -0,0 +1,175 @@ +package eu.seelenoede.getyourfilesoutthere; + +import java.io.File; +import java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; + +import javax.swing.JFrame; +import javax.swing.JTextField; + +import java.awt.BorderLayout; + +import javax.swing.JPanel; +import javax.swing.JLabel; +import javax.swing.JButton; +import javax.swing.SwingUtilities; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.Color; + +import javax.swing.JFileChooser; + +public class MainForm { + + private JFrame frmGetYourFiles; + private JTextField textField; + private JLabel lblPath; + private boolean alreadyRunning; + private JPanel panel_progress; + private JButton btnBrowse; + private File[] dirs; + private JLabel lblDone; + + /** + * Launch the application. + */ + public static void main(String[] args) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + try { + MainForm window = new MainForm(); + window.frmGetYourFiles.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the application. + */ + public MainForm() { + initialize(); + } + + /** + * Initialize the contents of the frame. + */ + private void initialize() { + alreadyRunning = false; + frmGetYourFiles = new JFrame("Get Your Files Out There"); + frmGetYourFiles.setTitle("Get Your Files Out There"); + frmGetYourFiles.getContentPane().setBackground(Color.LIGHT_GRAY); + frmGetYourFiles.setResizable(false); + frmGetYourFiles.setBackground(Color.WHITE); + frmGetYourFiles.setBounds(100, 100, 489, 150); + frmGetYourFiles.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frmGetYourFiles.setLocationRelativeTo(null); + frmGetYourFiles.getContentPane().setLayout(new BorderLayout(0, 0)); + + JPanel panel_path = new JPanel(); + panel_path.setBackground(Color.WHITE); + frmGetYourFiles.getContentPane().add(panel_path, BorderLayout.NORTH); + + lblPath = new JLabel("Path: "); + panel_path.add(lblPath); + + textField = new JTextField(); + textField.setEditable(false); + panel_path.add(textField); + textField.setColumns(30); + + btnBrowse = new JButton("Browse"); + btnBrowse.setBackground(Color.LIGHT_GRAY); + btnBrowse.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(alreadyRunning){ + return; + } + JFileChooser chooser = new JFileChooser(); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setMultiSelectionEnabled(true); + int val = chooser.showOpenDialog(null); + + if (val == JFileChooser.APPROVE_OPTION) { + dirs = chooser.getSelectedFiles(); + String selectedDirs = ""; + for (File dir:dirs) + { + selectedDirs = selectedDirs + "\"" + dir.getAbsolutePath() + "\"; "; + } + textField.setText(selectedDirs); + } + } + }); + panel_path.add(btnBrowse); + + JButton btnStart = new JButton("Start"); + btnStart.setSelected(true); + btnStart.setBackground(Color.LIGHT_GRAY); + + frmGetYourFiles.getRootPane().setDefaultButton(btnStart); + + btnStart.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + Thread noBlock = new Thread() { + public void run() { + resetElements(); + extractFiles(); + } + }; + if ((!alreadyRunning) & (dirs!=null)) { + noBlock.start(); + alreadyRunning = true; + } + + } + }); + + frmGetYourFiles.getContentPane().add(btnStart, BorderLayout.SOUTH); + + panel_progress = new JPanel(); + panel_progress.setBackground(Color.WHITE); + frmGetYourFiles.getContentPane().add(panel_progress, BorderLayout.CENTER); + + lblDone = new JLabel(""); + panel_progress.add(lblDone); + } + + private void extractFiles() { + + for(File dir:dirs) { + try { + String parentDir = dir.getCanonicalFile().getParent(); + + File[] files; + files = dir.listFiles(); + for(File file:files) { + Path target = FileSystems.getDefault().getPath(parentDir + "\\" + file.getName()); + + Files.move(file.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + } + } + catch (IOException e) { + e.printStackTrace(); + } + } + lblDone.setText("Done"); + alreadyRunning = false; + } + + private void resetElements() { + //lblExtract.setText(""); + //lblZip.setText(""); + lblDone.setText(""); + + //progressBar_Extraction.setValue(0); + //progressBar_Zip.setValue(0); + } + +} \ No newline at end of file diff --git a/src/eu/seelenoede/getyourfilesoutthere/SettingsFilter.java b/src/eu/seelenoede/getyourfilesoutthere/SettingsFilter.java deleted file mode 100644 index f331dab..0000000 --- a/src/eu/seelenoede/getyourfilesoutthere/SettingsFilter.java +++ /dev/null @@ -1,25 +0,0 @@ -package eu.seelenoede.getyourfilesoutthere; - -import java.io.File; -import java.io.FileFilter; -import java.util.ArrayList; - -public class SettingsFilter implements FileFilter { - - ArrayList extensions; - - SettingsFilter() { - extensions = new ArrayList(); - } - - @Override - public boolean accept(File pathname) { - String filePath = pathname.getAbsolutePath(); - String fileExtension = filePath.substring(filePath.lastIndexOf('.') + 1); - - if(extensions.contains(fileExtension)) - return true; - return false; - } - -}