Save selected files to a selected path keeping the original name

There's no system.file.saveDirectory function, so choosing a directory to save to gets a bit complicated.
Once you have the directory, you should be able to use system.file.writeFile with a generated directory + filename path, and system.file.readFileAsBytes to read the source file(s), as needed.

Choosing a directory with a GUI would look something like this:

from javax.swing import JFileChooser

fileChooser = JFileChooser()
fileChooser.fileSelectionMode = JFileChooser.DIRECTORIES_ONLY
result = fileChooser.showSaveDialog(None)
if result == JFileChooser.APPROVE_OPTION:
    directoryPath = fileChooser.selectedFile.path 
2 Likes