File manager rename and copy functions
Please add features to the file manager to allow copying an existing file into a new one and renaming files.
dgelessus last edited by dgelessus
Renaming files is already possible. Open the file in the editor, tap its title and then the little rename icon. For folders, go into the folder, switch to "Edit" mode, and then you have a rename icon next to the "Done" button.
For copying files I use a short script like this as an editor action:
import console import editor import os import shutil DOCUMENTS = os.path.expanduser("~/Documents") old_name = editor.get_path() new_name = os.path.join(DOCUMENTS, console.input_alert("Duplicate File", "Enter new name", os.path.relpath(old_name, DOCUMENTS))) if os.path.exists(new_name): console.hud_alert("Destination already exists", "error") else: shutil.copy(old_name, new_name) ##editor.open_file(os.path.relpath(new_name, DOCUMENTS)) # For old Pythonistas editor.open_file(new_name)
Of course this only works one file at a time. For copying multiple files stash is currently the best solution.
brumm last edited by
@brumm Really!? I will check that out?!
P.S. You might like interrobang: ‽
brumm last edited by
Yes, I love it (now that I know it). 😀
Thanks for the suggestions, @dgelessus.
The rename feature in the editor isn't enough. In my case, it's not even possible for one file.
As an experiment, I renamed a .pyui file to .json. I changed some coordinates from
[[x,y],[w,h]]structures. It worked in the app that used it, but when I renamed the file back to .pyui, all attempts to open it cause Pythonista itself to crash.
I know I can rename or copy files with function calls from the console or a program. However, the file manager should have this feature, too. It feels incomplete without them.
omz last edited by
@lsloan The UI editor doesn't handle malformed files very well. If you're in a crash loop, you can launch Pythonista by entering
pythonista://in Safari's address bar. This will skip restoring the previously-open files.
dgelessus last edited by
Of course that crashes Pythonista. You're changing the internal structure of a file that is not meant to be edited by hand. Okay, Pythonista should probably display an error instead of crashing entirely, but this is not exactly the normal use case of
The current state is also much better than what it was like in version 1.5. There the editor would refuse to open files with an unknown extension, even if they were text files, and when renaming it would automatically set the extension to
.pyif you used something other than
@omz Thanks, I'd forgotten about that trick.