marta-file-manager / marta-issues

An issue tracker for Marta File Manager.
https://marta.yanex.org/
368 stars 0 forks source link

Request: cut / paste to move files #321

Open rayshan opened 6 years ago

rayshan commented 6 years ago

Hello, thanks for your work on Marta. So far so good.

A lot of users coming from the Windows world are used to the pattern of copy / cut files, move to destination, then paste to copy and move files. May we have keyboard bindings for these actions, similar to what's in Finder?

yanex commented 6 years ago

Cmd+C/Cmd+V are already supported. Are you about the "cut" operation (Cmd+X)?

rayshan commented 6 years ago

You're right, Cmd+C/Cmd+V works. Yes cut operation defaulting to Cmd+X would make it complete.

ghost commented 6 years ago

In Finder it's CMD+C and then CMD+ALT+V so you do not have to decide if you want to copy or cut at the first step, it's only different at the second step, while pasting.

rayshan commented 6 years ago

@monouser7dig you're right, although I find this strange considering how cut / paste typically work. I'll remove "finder-like" from this issue.

janvr-at-q16 commented 5 years ago

I would love to have this as well!

ww7 commented 5 years ago

I'm also miss this simple routine feature

matusd2 commented 4 years ago

Hello, I really miss this feature! Do you plan to implement it?

Either Cmd+C > Cmd+Opt+V (like in Finder) or Cmd+X > Cmd+V.

notDavid commented 2 years ago

+1 vote for "Cmd+C and Cmd+Opt+V (like in Finder)".

Seems like a basic feature, and the current solution is somewhat cumbersome. I would like to suggest / be grateful if this would get a high priority :-)

chrisgrieser commented 2 years ago

I fully agree with the others. I am amazed that Marta can do a lot of pretty advanced stuff already out of the box, but moving a single file without the other pane seems a bit cumbersome.

Poitubaren commented 1 year ago

Hi, is there any update on this?

sleepymalc commented 11 months ago

@yanex Would like to get any update on this. This is still one of the most pain point I have when using Marta as my daily file manager.

manuelfitz commented 4 months ago

@sleepymalc @Poitubaren @chrisgrieser @notDavid @matusd2 @ww7 @janvr-at-q16 @rayshan

Hi guys, if you still look for a solution to this.

I wasted my day to find a solution for this. Here's how you can make pasting with Command+Option+V work:

  1. Create AppleScript Store the following AppleScript somewhere as .scpt file, i stored it at ~/Documents/AppleScripts with the name "move_to_folder.scpt" move_to_folder.txt Note: The file looks really strange when opening it in Text Editor as .txt file. After renaming in to .scpt it should open in Script Editor without any problems.

  2. Adapt Marta Preferences Create a gadget in the Marta preferences where you reference the created script. Adapt the first parameter of args as needed to reference the script from above.

gadgets [
    {
        id "gadget.copy.move_files"
        name "My Executable Runner"
        type "executable"

        executable "/usr/bin/osascript"
        args ["/Users/**<USER>**/Documents/AppleScripts/**move_to_folder.scpt**" "${active.folder.path}"]
        workingDirectory "${user.home}"
    }
]

Assign a keyBindings in preferences:

keyBindings {
    "Cmd+Opt+V" "gadget.copy.move_files"
}
  1. Check if it works

How it works

  1. The script checks if parameter1 is a valid folder (the path from marta received with the ${active.folder.path} from the gadget as argument)
  2. The script checks if files / folders are currently copied in the clipboard.
  3. The script accesses the files copied to clipboard and their full paths
  4. The script moves the files to the folder one by one by using shell script mv -n command. The -n argument is used to only move files which don't exist at the target. You can remove the -n if you want it to replace automatically.

Further Adaptions The script could also be adapted to ask if the files should be replaced and to show a status how many files were replaced and question dialogs can be implemented with display dialog in the Apple Script. I didn't need this functionality. And it was already a pain to get this working.

Issues I had I wanted to create a more advanced Plugin for Marta, but calling this Apple Script from a Marta Lua Plugin did result in taking forever to execute because querying the Clipboard to get the files / check if files are copied in the Apple Script takes almost half a Minute. I guess that this is some protection mechanism of Mac? Made some tests but could not find a working solution for that.

I used Lua Rocks for that, and I didn't find a way to directly interact with the Clipboard with Lua. That's why I went the AppleScript route. It's probably possible to implement the functionality with Objective C / Swift / whatever, but did not want to waste more time to implement this feature as I already did.

Topics for future If I would have gotten the Marta Plugin to work with this behavior I would have implemented the functionality to Cut files with Command+X and move the files with Command+V. But I think I won't put any more resources into this functionality. Unfortunately the things possible with the API currently did not support what I needed for this functionality. It's sad to see that there are not that much updates for Marta anymore. It's the best File Manager out there and only lacking some basic functionality.

smakhnist commented 3 weeks ago

It's November 2024, and the feature is still highly anticipated.

christopherotondo commented 1 week ago

Hi, I found a way for cutting operation, it is a gadget added to conf.json, though I am sure there is a better solution than this 😃. The idea is to move the file to tmp folder and with the copy from cut shortcut move it to the active folder in Marta. There is not Cmd+Z to this, but the file is not lost, it is in /tmp (or wherever you choose to add your cut location)

gadgets [ { "id" "gadget.action.cut_files" "name" "Cut Files" "type" "executable" "executable" "/bin/mv" "args" ["${active.selection.paths}" "/tmp/marta_cut/"] "workingDirectory" "${user.home}" } { "id" "gadget.action.paste_files" "name" "Paste Files" "type" "executable" "executable" "/bin/sh" "args" ["-c" "mv /tmp/marta_cut/* '${active.folder.path}'"] "workingDirectory" "${user.home}" } ]

I use it with the following keybindings but you can change it: "Cmd+X" "gadget.action.cut_files" "Shift+Cmd+V" "gadget.action.paste_files"

christopherotondo commented 6 days ago

I made a better alternative than my previous using python. You have to create 2 .py files cut_files.py and paste_cut_files.py. Still no cmd-Z but it should be possible with python.

Here is the gadget to add to the config file:

gadgets [ { "id" "gadget.action.cut_files" "name" "Cut Files" "type" "executable" "executable" "/usr/local/bin/python" "args" ["/Users//Documents/cut_files.py" "${active.selection.paths}"] "workingDirectory" "${user.home}" } { "id" "gadget.action.paste_cut_files" "name" "Paste Cut Files" "type" "executable" "executable" "/usr/local/bin/python" "args" ["/Users//Documents/paste_cut_files.py" "${active.folder.path}"] "workingDirectory" "${user.home}" } ]

you can edit the location of your 2 .py scripts and the also the temp folder.

cut_files.py code

import sys import shutil import os

def copy_rdp_files(selection_paths):

Ensure the destination directory exists

destination_dir = "/tmp/marta_cut"
os.makedirs(destination_dir, exist_ok=True)

# Loop over each selected path
for path in selection_paths:
    if os.path.isfile(path):
        # Move file to the destination directory
        destination = os.path.join(destination_dir, os.path.basename(path))
        shutil.move(path, destination)
        print(f"Moved file {path} to {destination}")
    elif os.path.isdir(path):
        # Move entire directory to the destination directory
        destination = os.path.join(destination_dir, os.path.basename(path))
        shutil.move(path, destination)
        print(f"Moved directory {path} to {destination}")
    else:
        print(f"{path} is not a valid file or directory")

if name == "main":

argv[1:] contains the paths passed from Marta

if len(sys.argv) > 1:
    # Process all the selected paths
    copy_rdp_files(sys.argv[1:])
else:
    print("No file or directory paths provided.")

and paste_cut_files.py:

import os import shutil import sys

def paste_files(destination_folder):

Directory where the cut files and directories are temporarily stored

cut_dir = "/tmp/marta_cut"

# Check if the destination is a directory
if os.path.exists(destination_folder) and not os.path.isdir(destination_folder):
    print(f"Error: {destination_folder} is a file, not a directory.")
    return

# Ensure the destination folder exists
os.makedirs(destination_folder, exist_ok=True)

# Move all files and directories from /tmp/marta_cut to the destination folder
for item_name in os.listdir(cut_dir):
    item_path = os.path.join(cut_dir, item_name)
    destination_path = os.path.join(destination_folder, item_name)

    if os.path.isfile(item_path):
        shutil.move(item_path, destination_path)
        print(f"Pasted file {item_path} to {destination_folder}")
    elif os.path.isdir(item_path):
        shutil.move(item_path, destination_path)
        print(f"Pasted directory {item_path} to {destination_folder}")
    else:
        print(f"{item_path} is not a valid file or directory and will be skipped.")

if name == "main": if len(sys.argv) > 1:

argv[1] is the destination folder passed by Marta

    paste_files(sys.argv[1])
else:
    print("No destination folder provided.")