initial commit
This commit is contained in:
commit
290d66c9ca
4 changed files with 203 additions and 0 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
bin
|
||||||
|
.settings
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2017 Seelenoede
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
5
README.md
Normal file
5
README.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
Extracts files from one or multiple folders and moves them to the parent folder.
|
||||||
|
|
||||||
|
TODOS:
|
||||||
|
- improve GUI
|
||||||
|
- add file filter
|
||||||
173
src/eu/seelenoede/getyourfilesoutthere/MainForm.java
Normal file
173
src/eu/seelenoede/getyourfilesoutthere/MainForm.java
Normal file
|
|
@ -0,0 +1,173 @@
|
||||||
|
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) {
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetElements() {
|
||||||
|
//lblExtract.setText("");
|
||||||
|
//lblZip.setText("");
|
||||||
|
lblDone.setText("");
|
||||||
|
|
||||||
|
//progressBar_Extraction.setValue(0);
|
||||||
|
//progressBar_Zip.setValue(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue