Save selected files to a selected path keeping the original name

hello everyone, I'm new here and I really can't find the solution or something that can guide me to do what I'm looking for...

select files and paste in another direction, keeping the original name, ideally selected the location that I want to paste the files

for example,

old_folder i have; file.py , contract.pdf , logo.img...

I want to select what I copy and where paste in
new_folder -> file.py (if I selected it)

Is it too complex or am I just drowning in a glass of water?

any possible solution?

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