megatools-ls(1)
===============

NAME
----
megatools ls - List files stored in the cloud


SYNOPSIS
--------
[verse]
'megatools ls' [-e] [-h] [--header] [-l] [-R] [-n] [-0] [<remotepaths>...]


DESCRIPTION
-----------

Lists files and folders stored on Mega.nz, optionally with details (handle,
size, date) and their public links.


OPTIONS
-------

--export::
-e::
	Also show the public link of each listed file and folder that has one
	(the column is empty for the others). ls doesn't create links; use
	man:megatools-export[1] for that.

--human::
-h::
	With `--long`, show file sizes in a human readable format (KiB, MiB,
	...).

--header::
	With `--long`, print a header describing the columns.

--long::
-l::
	Long listing format: the node handle, the owner's user handle, the node
	type, the file size, the modification date and the path. The type is
	0 for a file, 1 for a folder, 2 for /Root, 4 for /Trash and 10 for
	/Shared. Folders have `-` as the size.

--recursive::
-R::
	List the contents of folders recursively. This is the default when no
	paths are given.

--names::
-n::
	Show only the names of the nodes in the folder instead of their full
	paths, and not the folder itself. Works only with a single path and
	without `--recursive`.

--print0::
-0::
	Separate the paths with NUL characters instead of new lines, for
	`xargs -0`. Can't be combined with `--long`.

include::auth-options.txt[]
include::basic-options.txt[]

<remotepaths>::
	One or more remote paths to list. For a folder, the folder itself and
	its contents are listed (only the contents with `--names`). For a file,
	the file itself is listed.
+
Without paths, the entire remote filesystem is listed recursively. A path
that doesn't exist is reported and ls exits with status 1.


EXAMPLES
--------

* List all files:
+
------------
$ megatools ls
/Root
/Root/Backups
/Root/Backups/photo.jpg
/Root/README
/Shared
/Shared/Photos
/Trash
------------


* List the /Root folder with details:
+
------------
$ megatools ls -l /Root
3RsS2QwJ                2             - 2013-01-22 12:31:06 /Root
h5AsELXJ    Xz2tWWB5Dmo 1             - 2013-04-15 08:30:12 /Root/Backups
2FFSiaKZ    Xz2tWWB5Dmo 0          2686 2013-04-15 08:33:47 /Root/README
udtDgR7I    Xz2tWWB5Dmo 0    4405067776 2013-04-10 19:16:02 /Root/bigfile
------------


* The same with human readable sizes, a header, and only the names:
+
------------
$ megatools ls -lhn --header /Root
===================================================================================
Handle      Owner       T          Size Mod. Date           Filename
===================================================================================
h5AsELXJ    Xz2tWWB5Dmo 1             - 2013-04-15 08:30:12 Backups
2FFSiaKZ    Xz2tWWB5Dmo 0       2.6 KiB 2013-04-15 08:33:47 README
udtDgR7I    Xz2tWWB5Dmo 0       4.1 GiB 2013-04-10 19:16:02 bigfile
------------


* List a folder and everything below it:
+
------------
$ megatools ls -R /Root/Backups
/Root/Backups
/Root/Backups/2024
/Root/Backups/2024/photo.jpg
/Root/Backups/photo.jpg
------------


* Show the public links:
+
------------
$ megatools ls -e /Root
                                                                          /Root
https://mega.nz/folder/OUpqDYnr#RlE94awIQSELHiaKPUo4XA                    /Root/Backups
https://mega.nz/file/OFFRlbgR#k5rWmLp3mxB0gsq07Ii67PLd9L0wq4KondFLDlfH3Uw /Root/README
                                                                          /Root/bigfile
------------


* List a folder by its handle (e.g. one of two folders with the same name):
+
------------
$ megatools ls @h5AsELXJ
------------


* Remove all `.tmp` files below /Root/Backups:
+
------------
$ megatools ls -R -0 /Root/Backups | grep -z '\.tmp$' | xargs -0 -r megatools rm
------------


include::remote-paths.txt[]

include::footer.txt[]
