### Start MEGAcmd Server with Full Debugging Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/DEBUG.md Use the '--debug-full' argument to start the MEGAcmd server with the highest level of verbosity for both MEGAcmd and SDK logs. ```bash MEGAcmdServer.exe --debug-full ``` -------------------------------- ### System-wide Installation of MEGAcmd (Linux/macOS) Source: https://github.com/meganz/megacmd/blob/master/README.md Install MEGAcmd system-wide on Unix-based systems after building. This command installs 'mega-cmd', 'mega-cmd-server', and other related commands. It's recommended to use a Release build for installation. ```bash sudo cmake --install build/build-cmake-Release ``` -------------------------------- ### Sync Ignore Filter Examples Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/commands/sync-ignore.md Examples demonstrating various filter formats for including or excluding files and directories based on name, path, and type. These filters can be used with `sync-ignore --add` or `sync-ignore --remove`. ```bash -f:*.txt ``` ```bash +fg:work*.txt ``` ```bash -N:*.avi ``` ```bash -nr:.*foo.* ``` ```bash -d:private ``` -------------------------------- ### Install Targets for Apple Source: https://github.com/meganz/megacmd/blob/master/CMakeLists.txt Installs all targets as a bundle for Apple platforms. ```cmake if (APPLE) install(TARGETS ${all_targets} BUNDLE DESTINATION "./" ) elseif(NOT WIN32) set(PERMISSIONS755 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS ${PERMISSIONS755}) install(TARGETS ${all_targets} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/src/client/" DESTINATION ${CMAKE_INSTALL_BINDIR} FILE_PERMISSIONS ${PERMISSIONS755} FILES_MATCHING PATTERN "mega-*" PATTERN "*.cpp" EXCLUDE PATTERN "*.h" EXCLUDE PATTERN "mega-exec" EXCLUDE PATTERN "megacmd_completion.sh" EXCLUDE PATTERN "python" EXCLUDE PATTERN "win" EXCLUDE) install(FILES "${CMAKE_CURRENT_LIST_DIR}/src/client/megacmd_completion.sh" DESTINATION "etc/bash_completion.d" ) # generate 100-megacmd-inotify-limit.conf file and have it installed execute_process(COMMAND echo "fs.inotify.max_user_watches = 524288" OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/99-megacmd-inotify-limit.conf) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/99-megacmd-inotify-limit.conf DESTINATION "etc/sysctl.d" ) #Install vcpkg dynamic libraries in locations defined by GNUInstallDirs. if(CMAKE_BUILD_TYPE STREQUAL "Debug") SET(vcpkg_lib_folder "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/") else() SET(vcpkg_lib_folder "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/") endif() install(DIRECTORY "${vcpkg_lib_folder}" DESTINATION ${CMAKE_INSTALL_LIBDIR} FILES_MATCHING PATTERN "lib*.so*" PATTERN "*dylib*" #macOS PATTERN "manual-link" EXCLUDE PATTERN "pkgconfig" EXCLUDE) endif() #not WIN32 ``` -------------------------------- ### Get detailed help for a MEGAcmd command Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Use the --help flag with any command to get detailed information about its usage and options. ```bash mega-ls --help ``` -------------------------------- ### Download a file Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Use the 'get' command followed by the filename to download a file from MEGA Cloud. ```bash eg.email_1@example.co.nz:/$ ls Welcome to MEGA.pdf eg.email_1@example.co.nz:/$ get "Welcome to MEGA.pdf" TRANSFERING ||################################################################################||(1/1 MB: 100.00 %) Download finished: Welcome to MEGA.pdf TRANSFERING ||################################################################################||(1/1 MB: 100.00 %) ``` -------------------------------- ### Batch Export Script Example Source: https://context7.com/meganz/megacmd/llms.txt A bash script to find all MP4 video files in a specified folder, export them to get shareable links, and save the links to a text file. ```bash #!/bin/bash # Export all videos from a folder and save links to a file for file in $(mega-find /videos --pattern="*.mp4" --type=f); do link=$(mega-export -a -f "$file" | awk '{print $NF}') echo "$file: $link" >> video_links.txt done ``` -------------------------------- ### Example MEGAcmd and SDK Log Messages Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/DEBUG.md These log messages show information from both MEGAcmd and the SDK, including timestamps, log levels, source file, and line numbers. ```log 2025-02-07_16-47-56.662269 cmd DBG Registering state listener petition with socket: 85 [comunicationsmanagerfilesockets.cpp:189] 2025-02-07_16-47-56.662366 cmd DTL Unregistering no longer listening client. Original petition: registerstatelistener [comunicationsmanagerfilesockets.cpp:346] 2025-02-07_16-47-56.662671 sdk INFO Request (RETRY_PENDING_CONNECTIONS) starting [megaapi_impl.cpp:16964] ``` -------------------------------- ### Start MEGAcmd Interactive Shell Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Starts the MEGAcmd interactive shell. You can then issue commands directly within this shell. ```bash mega-cmd ``` -------------------------------- ### Logout and Login Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Use 'logout' to end the current session and 'login' to start a new one with specified credentials. ```bash eg.email_1@example.co.nz:/$ logout Logging out... MEGA CMD> login eg.email_2@example.co.nz Password: [SDK:info: 23:21:10] Fetching nodes ... [SDK:info: 23:21:12] Loading transfers from local cache [SDK:info: 23:21:12] Login complete as eg.email_2@example.co.nz ``` -------------------------------- ### Get Command Help Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Displays detailed help information for a specific command, such as 'ls', when used with the --help flag. ```bash ls --help ``` -------------------------------- ### Automated Backup Script Example Source: https://context7.com/meganz/megacmd/llms.txt A bash script that creates a compressed local backup, uploads it to MEGA, generates a time-limited share link, and then cleans up the local backup file. ```bash #!/bin/bash # Upload local backup and create time-limited share link BACKUP_FILE="/local/backup-$(date +%Y%m%d).tar.gz" REMOTE_PATH="/backups/" # Create local backup tar -czf "$BACKUP_FILE" /important/data/ # Upload to MEGA mega-put -c "$BACKUP_FILE" "$REMOTE_PATH" # Create 7-day expiring link mega-export -a -f --expire=7d "${REMOTE_PATH}$(basename $BACKUP_FILE)" # Clean up local file rm "$BACKUP_FILE" ``` -------------------------------- ### Windows Silent Installation Source: https://github.com/meganz/megacmd/blob/master/README.md Execute the MEGAcmd installer silently from the command prompt on Windows. This is useful for automated deployments. ```batch MEGAcmdSetup.exe /S ``` -------------------------------- ### Set Installation Directories for UNIX Source: https://github.com/meganz/megacmd/blob/master/CMakeLists.txt Configures installation directories and RPATH for UNIX systems. It overrides default paths and sets the RPATH based on CMAKE_INSTALL_PREFIX to ensure dynamic libraries are found correctly. ```cmake if(UNIX AND NOT APPLE) set(CMAKE_INSTALL_LIBDIR "opt/megacmd/lib") set(CMAKE_INSTALL_BINDIR "usr/bin") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) message(STATUS "Overriding default CMAKE_INSTALL_PREFIX to /") set(CMAKE_INSTALL_PREFIX "/" CACHE PATH "Default install path" FORCE) set(RPATH_FOR_DYNAMIC_LIBS "/${CMAKE_INSTALL_LIBDIR}") else() set(RPATH_FOR_DYNAMIC_LIBS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") endif() list( APPEND CMAKE_INSTALL_RPATH "${RPATH_FOR_DYNAMIC_LIBS}") endif() ``` -------------------------------- ### Set MEGAcmd Log Level via Environment Variable Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/DEBUG.md Set the MEGACMD_LOGLEVEL environment variable to 'FULLVERBOSE' to start the server with increased log levels. ```bash export MEGACMD_LOGLEVEL=FULLVERBOSE ``` -------------------------------- ### Find Command Help with PCRE Option Source: https://github.com/meganz/megacmd/blob/master/README.md This example shows the help output for the `find` command, specifically highlighting the `--pattern` option which supports Perl Compatible Regular Expressions. ```bash find --help ... Options: --pattern=PATTERN Pattern to match (Perl Compatible Regular Expressions) ``` -------------------------------- ### WEBDAV Served Locations Output Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/WEBDAV.md This is an example of the output when listing currently served WEBDAV locations. It shows the local path and the corresponding WEBDAV URL. ```text WEBDAV SERVED LOCATIONS: /path/mega/folder: http://127.0.0.1:4443/XXXXXXX/myfolder /path/to/myfile.mp4: http://127.0.0.1:4443/YYYYYYY/myfile.mp4 ``` -------------------------------- ### MEGAcmd Find Command Correct Path Example Source: https://github.com/meganz/megacmd/blob/master/README.md Shows the expected output of the `find` command when executed within a specific directory, illustrating correct path interpretation. ```bash /toshare/x ``` -------------------------------- ### Publicly Export Files with Time-Limited Access Source: https://github.com/meganz/megacmd/blob/master/README.md Iterate through files matching a pattern in a MEGA folder, create a secure export for each, and print the export URL. This example finds all MPEG files from May 2015. ```bash for i in $(mega-find /enterprise/video/promotional2015/may --pattern="*mpeg"); do mega-export -a $i | awk '{print $4}'; done ``` -------------------------------- ### Sync Status Monitor Script Example Source: https://context7.com/meganz/megacmd/llms.txt A bash script that checks the status of MEGA syncs and alerts if any errors are detected. It outputs the sync status and exits with an error code if issues are found. ```bash #!/bin/bash # Check sync status and alert if issues STATUS=$(mega-sync --output-cols=STATUS | tail -n +2) if echo "$STATUS" | grep -q "ERROR"; then echo "Sync error detected!" mega-sync exit 1 fi echo "All syncs healthy" ``` -------------------------------- ### Upload a directory Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Use 'mkdir' to create a directory, 'cd' to navigate into it, and 'put' to upload the contents of a local directory to MEGA Cloud. ```bash eg.email_1@example.co.nz:/$ mkdir my-pictures eg.email_1@example.co.nz:/$ cd my-pictures/ eg.email_1@example.co.nz:/my-pictures$ put C:\Users\MYWINDOWSUSER\Pictures TRANSFERING ||################################################################################||(1/1 MB: 100.00 %) Upload finished: C:\Users\MYWINDOWUSER\Pictures TRANSFERING ||################################################################################||(1/1 MB: 100.00 %) ``` -------------------------------- ### Establish and View Backups in MEGAcmd Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Demonstrates setting up a recurring backup task with specified parameters like period and number of backups using the `backup` command. It also shows how to view the status of established backups. ```bash eg.email@example.co.nz:/$ backup c:/cmake /cmake-backup --period="0 0 4 * * *" --num-backups=3 Backup established: c:/cmake into /cmake-backup period="0 0 4 * * *" Number-of-Backups=3 ``` ```bash eg.email@example.co.nz:/$ backup TAG LOCALPATH REMOTEPARENTPATH STATUS 166 \?/c:\cmake /cmake-backup COMPLETE ``` ```bash eg.email@example.co.nz:/$ backup -h TAG LOCALPATH REMOTEPARENTPATH STATUS 166 \?/c:\cmake /cmake-backup COMPLETE -- HISTORY OF BACKUPS -- NAME DATE STATUS FILES FOLDERS cmake_bk_20180426133300 26Apr2018 13:33:00 COMPLETE 0 92 ``` -------------------------------- ### Create Directories Source: https://context7.com/meganz/megacmd/llms.txt Create directories in MEGA cloud storage. Use -p to create nested directory structures. ```bash mega-mkdir /new-folder ``` ```bash mega-mkdir -p /parent/child/grandchild ``` -------------------------------- ### Navigate and List Directories in MEGAcmd Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Demonstrates basic directory navigation using `pwd`, `ls`, and `cd` commands within the MEGAcmd environment. Shows how to check the current directory and list contents. ```bash eg.email_1@example.co.nz:/my-pictures$ pwd /my-pictures ``` ```bash eg.email_1@example.co.nz:/my-pictures$ ls Pictures ``` ```bash eg.email_1@example.co.nz:/my-pictures$ cd Pictures/ ``` ```bash eg.email_1@example.co.nz:/my-pictures/my-pictures$ ls Camera Roll Feedback Saved Pictures megacmdpkg.gif megacmdpkg_80.gif megacmdpkg_gray.gif ``` ```bash eg.email_1@example.co.nz:/my-pictures/my-pictures$ pwd /my-pictures/Pictures ``` ```bash eg.email_1@example.co.nz:/my-pictures/my-pictures$ cd / ``` -------------------------------- ### List Files and Directories Source: https://context7.com/meganz/megacmd/llms.txt List files and folders in a MEGA path. Options include detailed listing (-l), human-readable sizes (-lh), recursive listing (-R), tree view (--tree), wildcard patterns, PCRE regex (--use-pcre), showing versions (--versions), and file handles (--show-handles). ```bash mega-ls ``` ```bash mega-ls -l ``` ```bash mega-ls -lh ``` ```bash mega-ls -R /my-folder ``` ```bash mega-ls --tree /my-folder ``` ```bash mega-ls "*.pdf" ``` ```bash mega-ls --use-pcre ".*\.(jpg|png)$" ``` ```bash mega-ls --versions /my-folder ``` ```bash mega-ls --show-handles ``` -------------------------------- ### List of Supported Platforms Source: https://github.com/meganz/megacmd/blob/master/build/SynologyNAS/README.md These are the possible platform arguments for the Docker build command. ```text alpine alpine4k apollolake armada37xx armada38x avoton broadwell broadwellnk broadwellnkv2 broadwellntbap bromolow braswell denverton epyc7002 geminilake grantley kvmx64 monaco purley r1000 rtd1296 rtd1619b v1000 ``` -------------------------------- ### Sign up for a new MEGA account Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Use the 'signup' command to create a new MEGA account. You will be prompted to set and confirm a password. A confirmation link will be sent to your email. ```bash MEGA CMD> signup eg.email_1@example.co.nz --name="test1" New Password: Retype New Password: Account created succesfully. You will receive a confirmation link. Use "confirm" with the provided link to confirm that account ``` ```bash MEGA CMD> confirm https://mega.nz/#confirmQFSfjtUkExc5M2Us6q5d-klx60RfxVbxjhk eg.email_1@example.co.nz Password: Account eg.email_1@example.co.nz confirmed succesfully. You can login with it now ``` ```bash MEGA CMD> signup eg.email_2@example.co.nz --name="test2" New Password: Retype New Password: Account created succesfully. You will receive a confirmation link. Use "confirm" with the provided link to confirm that account ``` ```bash MEGA CMD> confirm https://mega.nz/#confirmcz7Ss68ChhMKk8WEFTQCqLMHJg8esAEEpQE eg.email_2@example.co.nz Password: Account eg.email_2@example.co.nz confirmed succesfully. You can login with it now ``` -------------------------------- ### Serve Files via WebDAV in MEGAcmd Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Illustrates how to share a local file using the WebDAV protocol with a specified port. It provides the URL for accessing the shared file and shows how to manage active WebDAV shares. ```bash eg.email@example.co.nz:/$ webdav myfile.tif --port=1024 Serving via webdav myfile.tif: http://127.0.0.1:1024/5mYHQT4B/myfile.tif ``` ```bash eg.email@example.co.nz:/$ webdav WEBDAV SERVED LOCATIONS: /myfile.tif: http://127.0.0.1:1024/5mYHQT4B/myfile.tif ``` ```bash eg.email@example.co.nz:/$ webdav -d myfile.tif myfile.tif no longer served via webdav ``` -------------------------------- ### Run Docker Container Source: https://github.com/meganz/megacmd/blob/master/build/SynologyNAS/README.md After building the image, run this command to start a container named 'megacmd-dms' in detached mode. ```bash docker run -d --name megacmd-dms megacmd-dms-build-env ``` -------------------------------- ### Log in to a MEGA account Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Use the 'login' command followed by your account email to log in. You will be prompted for your password. The command shows SDK information during the login process. ```bash MEGA CMD> login eg.email_1@example.co.nz Password: [SDK:info: 23:19:14] Fetching nodes ... Fetching nodes ||########################################||(38/38 MB: 100.00 %) [SDK:info: 23:19:17] Loading transfers from local cache [SDK:info: 23:19:17] Login complete as eg.email_1@example.co.nz ``` -------------------------------- ### Include MEGAcmd and SDK Options Source: https://github.com/meganz/megacmd/blob/master/CMakeLists.txt Includes CMake option files for MEGAcmd and the SDK, allowing for configurable build features and dependencies. ```cmake include(megacmd_options) #Load first MEGAcmd's options (that we have prevalescence over SDK (e.g libuv) ``` ```cmake include(sdklib_options) #load default sdk's ``` -------------------------------- ### Show Outgoing Contact Requests Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/commands/showpcr.md Use the --out flag to display only outgoing contact requests. This command requires no additional setup. ```bash showpcr --out ``` -------------------------------- ### Show Incoming Contact Requests Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/commands/showpcr.md Use the --in flag to display only incoming contact requests. This command requires no additional setup. ```bash showpcr --in ``` -------------------------------- ### Preview Command Usage Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/commands/preview.md This snippet details the usage of the `preview` command for handling file previews. It covers both downloading and uploading previews, along with the option to set a specific preview file. ```APIDOC ## preview ### Description To download/upload the preview of a file. ### Usage `preview [-s] remotepath localpath` ### Options - `-s` (flag) - Optional - Sets the preview to the specified file. If this option is not indicated, the command will download the preview. ``` -------------------------------- ### Get Git Commit Hash Source: https://github.com/meganz/megacmd/blob/master/CMakeLists.txt Executes a Git command to obtain the short commit hash of the SDK. The output is stored in the SDK_COMMIT_HASH variable. ```cmake execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/sdk OUTPUT_VARIABLE SDK_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ) ``` -------------------------------- ### Login and view incoming invitations Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Log in with a user account and then use 'showpcr' to view incoming pending contact requests. ```bash MEGA CMD> login eg.email_2@example.co.nz Password: [SDK:info: 23:21:10] Fetching nodes ... [SDK:info: 23:21:12] Loading transfers from local cache [SDK:info: 23:21:12] Login complete as eg.email_2@example.co.nz eg.email_2@example.co.nz:/$ showpcr Incoming PCRs: eg.email_1@example.co.nz (id: 47Xhz6wvVTk, creation: Thu, 26 Apr 2018 11:20:09 +1200, modification: Thu, 26 Apr 2018 11:20:09 +1200) ``` -------------------------------- ### Set Qt Creator VCPKG Skip Source: https://github.com/meganz/megacmd/blob/master/CMakeLists.txt Disables automatic VCPKG setup by Qt Creator to allow for custom triplet and path configurations. ```cmake set(QT_CREATOR_SKIP_VCPKG_SETUP TRUE CACHE BOOL "") ``` -------------------------------- ### Display Help Information in MEGAcmd Source: https://github.com/meganz/megacmd/blob/master/README.md List all available commands in the MEGAcmd interactive shell. For more detailed information on a specific command, use 'command --help'. ```bash help ``` -------------------------------- ### Get Help for a Specific Non-Interactive Command Source: https://github.com/meganz/megacmd/blob/master/README.md Retrieve detailed help for a specific non-interactive MEGAcmd command. Replace 'mega-command' with the actual command name. ```bash mega-command --help ``` -------------------------------- ### Add and Monitor Syncs in MEGAcmd Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Shows how to initiate a new synchronization task between a local directory and a remote MEGA path using the `sync` command. Also demonstrates how to monitor the status of active syncs. ```bash email_1@example.co.nz:/$ sync c:\Go go-backup/ Added sync: //?/c:\Go to /go-backup ``` ```bash email_1@example.co.nz:/$ sync ID LOCALPATH REMOTEPATH RUN_STATE STATUS ERROR SIZE FILES DIRS WOOmFwZfQwM \?/c:\Go /go-backup Running Syncing NO 119.13 KB 10 97 ``` ```bash email_1@example.co.nz:/$ sync ID LOCALPATH REMOTEPATH RUN_STATE STATUS ERROR SIZE FILES DIRS WOOmFwZfQwM \?/c:\Go /go-backup Running Syncing NO 61.22 MB 1252 463 ``` ```bash email_1@example.co.nz:/$ sync ID LOCALPATH REMOTEPATH RUN_STATE STATUS ERROR SIZE FILES DIRS WOOmFwZfQwM \?/c:\Go /go-backup Running Syncing NO 232.94 MB 4942 773 ``` ```bash email_1@example.co.nz:/$ sync ID LOCALPATH REMOTEPATH RUN_STATE STATUS ERROR SIZE FILES DIRS WOOmFwZfQwM \?/c:\Go /go-backup Running Synced NO 285.91 MB 7710 1003 ``` ```bash email_1@example.co.nz:/$ sync ID LOCALPATH REMOTEPATH RUN_STATE STATUS ERROR SIZE FILES DIRS WOOmFwZfQwM \?/c:\Go /go-backup Running Synced NO 268.53 MB 7306 961 ``` -------------------------------- ### Show Sync Ignore Filters Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/commands/sync-ignore.md Use the `--show` option to display the current ignore filters for a specific sync ID, local path, or the default configuration. If no action is provided, filters are shown by default. ```bash sync-ignore --show ID ``` ```bash sync-ignore --show localpath ``` ```bash sync-ignore --show DEFAULT ``` -------------------------------- ### Change Backup Period in MEGAcmd Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/BACKUPS.md Modifies the backup schedule period for a specific backup identified by its tag. This example sets the period to 2 hours. ```bash backup 4 --period=2h ``` -------------------------------- ### Configure RPATH for macOS Source: https://github.com/meganz/megacmd/blob/master/CMakeLists.txt Sets up the RPATH for macOS to include the installation library directory. This ensures that dynamic libraries are correctly located at runtime on Apple systems. ```cmake if(APPLE) set(CMAKE_MACOSX_RPATH 1) get_filename_component(ABSOLUTE_RPATH_LIBS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} ABSOLUTE) list(APPEND CMAKE_INSTALL_RPATH ${ABSOLUTE_RPATH_LIBS} ) message(STATUS "Added CMAKE_INSTALL_LIBDIR=${ABSOLUTE_RPATH_LIBS} to rpath: ${CMAKE_INSTALL_RPATH}") endif() ``` -------------------------------- ### Project Definition Source: https://github.com/meganz/megacmd/blob/master/CMakeLists.txt Defines the main project 'MEGAcmd' with its version and a description. This is a standard CMake command to initialize the project. ```cmake project(MEGAcmd VERSION ${MEGACMD_MAJOR_VERSION}.${MEGACMD_MINOR_VERSION}.${MEGACMD_MICRO_VERSION} DESCRIPTION "MEGAcmd" ) ``` -------------------------------- ### Add MEGAcmd to Windows PowerShell PATH Source: https://github.com/meganz/megacmd/blob/master/README.md Append the MEGAcmd installation directory to the PATH environment variable in PowerShell. This allows running client commands directly. ```powershell $env:PATH += ";$env:LOCALAPPDATA\MEGAcmd" ``` -------------------------------- ### Get Help for Non-Interactive Commands Source: https://github.com/meganz/megacmd/blob/master/README.md Obtain help information specifically for non-interactive MEGAcmd commands. This is useful for understanding command-line usage and options when not in the interactive shell. ```bash mega-help --non-interactive ``` -------------------------------- ### Launch MEGAcmd Shell in Windows PowerShell Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Start the interactive MEGAcmd shell from within a Windows PowerShell session. Ensure the MEGAcmd directory is added to your PATH first. ```powershell MEGAcmdShell ``` -------------------------------- ### View account details Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Use the 'whoami -l' command to display detailed information about the logged-in user's account, including storage, active sessions, and subscription details. ```bash eg.email_1@example.co.nz:/$ whoami -l Account e-mail: eg.email_1@example.co.nz Available storage: 50.00 GBytes In ROOT: 146... KBytes in 1 file(s) and 0 folder(s) In INBOX: 0.00 Bytes in 0 file(s) and 0 folder(s) In RUBBISH: 0.00 Bytes in 0 file(s) and 0 folder(s) Total size taken up by file versions: 0.00 Bytes Pro level: 0 Subscription type: Account balance: Current Active Sessions: * Current Session Session ID: m3a8eluyPdo Session start: 4/26/2018 11:43:12 AM Most recent activity: 4/26/2018 11:43:13 AM IP: 122.56.56.232 Country: NZ User-Agent: MEGAcmd/0.9.9.0 (Windows 10.0.16299) MegaClient/3.3.5 1 active sessions opened ``` -------------------------------- ### MEGAcmd Find Command Error Example Source: https://github.com/meganz/megacmd/blob/master/README.md Demonstrates an error scenario when using the `find` command with an absolute path that is not correctly interpreted, likely due to path discrepancies. ```bash [err: 12:21:51] Couldn't find /toshare/x ``` -------------------------------- ### Build Docker Image for Synology NAS Source: https://github.com/meganz/megacmd/blob/master/build/SynologyNAS/README.md Use this command to build a Docker container for cross-compiling MEGAcmd for Synology NAS. Replace `` with the target architecture. The working directory must be the MEGAcmd repository. ```bash docker build -t megacmd-dms-build-env -f $PWD/build/SynologyNAS/synology-cross-build.dockerfile $PWD --build-arg PLATFORM= ``` -------------------------------- ### Configure Folder Synchronization with mega-sync Source: https://context7.com/meganz/megacmd/llms.txt Set up bidirectional synchronization between local and remote MEGA folders using mega-sync. Commands include creating, listing, viewing, pausing, resuming, and deleting sync configurations. ```bash # Create new sync mega-sync /local/folder /remote/folder ``` ```bash # List all syncs mega-sync ``` ```bash # View specific sync details mega-sync ABC123xyz ``` ```bash # Pause a sync mega-sync --pause ABC123xyz ``` ```bash # Resume a paused sync mega-sync --enable ABC123xyz ``` ```bash # Delete sync configuration (keeps files) mega-sync --delete ABC123xyz ``` ```bash # Show with custom columns mega-sync --output-cols=ID,LOCALPATH,STATUS ``` -------------------------------- ### List Configured Backups in MEGAcmd Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/BACKUPS.md Lists all configured backups, showing their tag, local path, remote parent path, and status. The tag can be used to manage individual backups. ```bash backup ``` -------------------------------- ### Get Help for a Specific Command in MEGAcmd Source: https://github.com/meganz/megacmd/blob/master/README.md Obtain detailed help information for a specific command within the MEGAcmd interactive shell. Replace 'command' with the actual command name. ```bash command --help ``` -------------------------------- ### Execute MEGAcmd Commands in Windows PowerShell Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Run scriptable MEGAcmd commands in PowerShell after ensuring the MEGAcmd directory is in your PATH. This example demonstrates changing directory and listing contents. ```powershell $env:PATH += ";$env:LOCALAPPDATA\MEGAcmd" mega-cd /my/favourite/folder mega-ls ``` -------------------------------- ### Establish Synchronization Source: https://github.com/meganz/megacmd/blob/master/README.md Use this command to synchronize local folders with your MEGA account. It performs a two-way sync. ```bash sync /path/to/local/folder /folder/in/mega ``` -------------------------------- ### Add MEGAcmd to Windows Command Prompt PATH Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Modify the PATH environment variable in the Windows Command Prompt to include the MEGAcmd installation directory. This enables the use of scriptable commands. ```cmd set PATH=%LOCALAPPDATA%\MEGAcmd;%PATH% ``` -------------------------------- ### mkdir Command Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/commands/mkdir.md Creates a directory or a directories hierarchy. The -p option allows for recursive creation. ```APIDOC ## mkdir Command ### Description Creates a directory or a directories hierarchy. ### Usage `mkdir [-p] remotepath` ### Options - **-p** (boolean) - Optional - Allow recursive directory creation. ### Parameters #### Path Parameters - **remotepath** (string) - Required - The path of the directory to create. ``` -------------------------------- ### Remove Local Directory in Windows Command Prompt Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md This example shows how to remove a local directory using the `rmdir /s` command in a Windows command prompt. It requires confirmation before deletion. ```batch C:\Users\ME>rmdir /s c:\go\blog c:\go\blog, Are you sure (Y/N)? Y ``` -------------------------------- ### Serve a MEGA Folder via FTP Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/FTP.md Use this command to configure an FTP server that serves a specified MEGA folder. The command provides a URL for accessing the folder, which can then be configured on your operating system. ```bash ftp /path/mega/folder ``` -------------------------------- ### List All FUSE Mounts Source: https://context7.com/meganz/megacmd/llms.txt List all configured FUSE mounts managed by MEGA CMD. ```bash mega-fuse-show ``` -------------------------------- ### Show Delayed Uploads Max Attempts Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/commands/sync-config.md Shows the maximum number of times a file can change in quick succession before it starts to be delayed. This is part of the sync configuration for handling frequently changing files. ```bash sync-config --delayed-uploads-max-attempts ``` -------------------------------- ### Execute MEGAcmd Commands in Windows Command Prompt Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Run scriptable MEGAcmd commands in the Windows Command Prompt after setting the PATH. This example shows changing directory and listing folder contents. ```cmd set PATH=%LOCALAPPDATA%\MEGAcmd;%PATH% mega-cd /my/favourite/folder mega-ls ``` -------------------------------- ### Serve Folder via WebDAV with External Access Source: https://context7.com/meganz/megacmd/llms.txt Serve a local folder via WebDAV and allow external access. Use the --public flag to make it accessible from outside localhost. ```bash mega-webdav /cloud/media --public --port=8080 ``` -------------------------------- ### Configure Folder Backup with MEGAcmd Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/BACKUPS.md Configures a backup of a local folder to a remote MEGA path. The backup runs daily at 4 AM UTC and keeps the last 10 copies. A first backup is performed immediately. ```bash backup /path/mega/folder /remote/path --period="0 0 4 * * *" --num-backups=10 ``` -------------------------------- ### GET /download Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/commands/get.md Downloads a remote file, folder, or public link from MEGA. Handles both direct remote paths and exported public links. Supports options for background downloads, merging content, ignoring quota warnings, and decrypting password-protected links. ```APIDOC ## GET /download ### Description Downloads a remote file/folder or a public link. ### Method GET ### Endpoint `/download` ### Parameters #### Path Parameters - **exportedlink|remotepath** (string) - Required - The remote path to the file or folder, or an exported public link. - **localpath** (string) - Optional - The local destination path for the download. Defaults to the current directory. #### Query Parameters - **-m** (boolean) - Optional - If the folder already exists, merge its contents with the downloaded one, preserving existing files. - **-q** (boolean) - Optional - Queue download: execute in the background. Do not wait for it to complete. - **--ignore-quota-warn** (boolean) - Optional - Ignore quota surpassing warnings. The download will be attempted anyway. - **--use-pcre** (boolean) - Optional - Use PCRE (Perl Compatible Regular Expressions) for matching. - **--password=PASSWORD** (string) - Optional - Password to decrypt a password-protected link. Avoid using passwords containing " or '. ### Request Example ```bash megacmd get /docs/report.pdf /local/downloads/ megacmd get "https://mega.nz/folder/AbCdEfGh!JkLmNoPqRsTuVwXyZ" /my_shared_folder megacmd get -q --password=MySecretPassword "https://mega.nz/file/1a2b3c4d!e5f6g7h8i9j0k1l2m3n4o5p6" "./downloads/secret_file.zip" ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. - **message** (string) - A message describing the result of the download operation. #### Response Example ```json { "status": "success", "message": "Download completed successfully." } ``` #### Error Response (e.g., 400, 404, 500) - **status** (string) - Indicates the failure of the operation. - **message** (string) - A detailed error message. #### Error Response Example ```json { "status": "error", "message": "File not found or access denied." } ``` ``` -------------------------------- ### Browse API Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Commands for navigating and interacting with the remote file system. ```APIDOC ## cd ### Description Changes the current remote folder. ### Method POST ### Endpoint /api/remote/cd ### Parameters #### Query Parameters - **remotepath** (string) - Required - The path to the remote folder. ### Request Example ```json { "remotepath": "/Documents/Work" } ``` ### Response #### Success Response (200) - **current_path** (string) - The new current remote path. #### Response Example ```json { "current_path": "/Documents/Work" } ``` ``` ```APIDOC ## lcd ### Description Changes the current local folder for the interactive console. ### Method POST ### Endpoint /api/local/cd ### Parameters #### Query Parameters - **localpath** (string) - Required - The path to the local folder. ### Request Example ```json { "localpath": "/Users/username/Downloads" } ``` ### Response #### Success Response (200) - **current_path** (string) - The new current local path. #### Response Example ```json { "current_path": "/Users/username/Downloads" } ``` ``` ```APIDOC ## ls ### Description Lists files and folders in a remote path. ### Method GET ### Endpoint /api/remote/ls ### Parameters #### Query Parameters - **remotepath** (string) - Optional - The path to list. Defaults to the current remote directory. - **halRr** (boolean) - Optional - Flags for listing details (human-readable, all, long format, recursive, reverse). - **show-handles** (boolean) - Optional - Show node handles. - **tree** (boolean) - Optional - Display output as a tree. - **versions** (boolean) - Optional - Show file versions. - **use-pcre** (boolean) - Optional - Use Perl Compatible Regular Expressions for filtering. - **show-creation-time** (boolean) - Optional - Show creation time. - **time-format** (string) - Optional - Specifies the time format for timestamps. ### Response #### Success Response (200) - **items** (array) - A list of items in the directory. - **name** (string) - The name of the file or folder. - **size** (integer) - The size in bytes. - **type** (string) - 'file' or 'folder'. - **modified_time** (string) - Last modified timestamp. #### Response Example ```json { "items": [ { "name": "document.txt", "size": 1024, "type": "file", "modified_time": "2023-10-27T10:00:00Z" }, { "name": "Photos", "size": 0, "type": "folder", "modified_time": "2023-10-26T09:00:00Z" } ] } ``` ``` ```APIDOC ## pwd ### Description Prints the current remote folder path. ### Method GET ### Endpoint /api/remote/pwd ### Response #### Success Response (200) - **current_path** (string) - The current remote directory path. #### Response Example ```json { "current_path": "/Documents/Work" } ``` ``` ```APIDOC ## lpwd ### Description Prints the current local folder path for the interactive console. ### Method GET ### Endpoint /api/local/pwd ### Response #### Success Response (200) - **current_path** (string) - The current local directory path. #### Response Example ```json { "current_path": "/Users/username/Downloads" } ``` ``` ```APIDOC ## attr ### Description Lists or updates node attributes. ### Method GET/PUT ### Endpoint /api/nodes/attributes ### Parameters #### Query Parameters - **remotepath** (string) - Required - The path to the node. - **attribute** (string) - Required if setting/deleting - The name of the attribute. - **value** (string) - Required if setting - The value of the attribute. - **force-non-official** (boolean) - Optional - Force non-official attribute handling. - **s** (boolean) - Optional - Set attribute. - **d** (boolean) - Optional - Delete attribute. - **print-only-value** (boolean) - Optional - Only print the attribute value. ### Request Example (Set Attribute) ```json { "remotepath": "/Documents/report.docx", "attribute": "custom_tag", "value": "important" } ``` ### Response #### Success Response (200) - **attributes** (object) - A key-value map of node attributes. #### Response Example ```json { "attributes": { "custom_tag": "important" } } ``` ``` ```APIDOC ## du ### Description Prints the size used by files and folders. ### Method GET ### Endpoint /api/disk/usage ### Parameters #### Query Parameters - **remotepath** (string) - Optional - The path(s) to calculate disk usage for. Defaults to the current directory. - **h** (boolean) - Optional - Human-readable format for size. - **versions** (boolean) - Optional - Include size of file versions. - **use-pcre** (boolean) - Optional - Use Perl Compatible Regular Expressions for filtering paths. ### Response #### Success Response (200) - **usage** (object) - Disk usage information. - **path** (string) - The path for which usage is calculated. - **size** (integer) - The total size in bytes. #### Response Example ```json { "usage": [ { "path": "/Documents", "size": 536870912 } ] } ``` ``` ```APIDOC ## find ### Description Finds nodes matching specified criteria. ### Method GET ### Endpoint /api/find ### Parameters #### Query Parameters - **remotepath** (string) - Optional - The path to search within. Defaults to the root. - **pattern** (string) - Optional - The pattern to match filenames against. - **type** (string) - Optional - Type of node to find ('d' for directory, 'f' for file). - **mtime** (string) - Optional - Modification time constraint (e.g., '>', '<', '=' with a timestamp). - **size** (string) - Optional - Size constraint (e.g., '>', '<', '=' with a size value). - **use-pcre** (boolean) - Optional - Use Perl Compatible Regular Expressions for the pattern. - **time-format** (string) - Optional - Specifies the time format for timestamps. - **show-handles** (boolean) - Optional - Show node handles. - **print-only-handles** (boolean) - Optional - Only print node handles. - **l** (boolean) - Optional - Long listing format. ### Response #### Success Response (200) - **nodes** (array) - A list of found nodes. - **name** (string) - The name of the node. - **path** (string) - The full path to the node. - **type** (string) - 'file' or 'folder'. - **size** (integer) - The size in bytes. - **modified_time** (string) - Last modified timestamp. #### Response Example ```json { "nodes": [ { "name": "report.pdf", "path": "/Documents/report.pdf", "type": "file", "size": 204800, "modified_time": "2023-10-27T11:00:00Z" } ] } ``` ``` ```APIDOC ## mount ### Description Lists all the root nodes available for mounting. ### Method GET ### Endpoint /api/mounts ### Response #### Success Response (200) - **mounts** (array) - A list of root nodes. - **id** (string) - The ID of the root node. - **name** (string) - The name of the root node. - **type** (string) - The type of the node (e.g., 'cloud drive'). #### Response Example ```json { "mounts": [ { "id": "root123", "name": "My Cloud Drive", "type": "cloud drive" } ] } ``` ``` -------------------------------- ### Import Folder Link with MEGA CMD Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Use the 'import' command followed by a MEGA folder link to import the contents of that folder into your current directory. The command confirms the completion of the folder import. ```bash eg.email_2@example.co.nz:/$ import https://mega.nz/#F!iaZlEBIL!mQD3rFuJhKov0sco-6s9xg Imported folder complete: /Pictures ``` -------------------------------- ### Serve a File for Streaming via WEBDAV Source: https://github.com/meganz/megacmd/blob/master/contrib/docs/WEBDAV.md Serve a single file via WEBDAV for direct streaming access. This is useful for media files like videos. ```bash webdav /path/to/myfile.mp4 ``` -------------------------------- ### Share Promotional Videos via Script Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md This bash script iterates through all MPEG files in a specified MEGA directory, exports them, and prints their shareable links. It demonstrates using `mega-find` and `mega-export` in a loop. ```bash for i in $(mega-find /enterprise/video/promotional2015/may --pattern="*mpeg") do mega-export -a $i | awk '{print $4}'; done ``` -------------------------------- ### Clone MEGAcmd Repository and Update Submodules Source: https://github.com/meganz/megacmd/blob/master/README.md Use this command to clone the MEGAcmd repository and initialize all its submodules recursively. Ensure you are in the desired parent directory before running. ```bash git clone https://github.com/meganz/MEGAcmd.git cd MEGAcmd && git submodule update --init --recursive ``` -------------------------------- ### View open MEGAcmd sessions Source: https://github.com/meganz/megacmd/blob/master/UserGuide.md Use 'whoami -l' to see all active sessions across your devices. Sessions can be killed using the 'killsession' command. ```bash whoami -l ```