Memory stick file inventory

I’m trying to create an inventory of the contents of about twenty memory sticks, used over the last 15 years.

If I plug a stick into my hp desktop running ubuntu 22.04, it often shows a list of folders longer than can be seen on screen.

Trying to take a screen shot, which would list the file names visible, I can only get part of the contents, and need to take several shots, and paste them together to get all the contents of that particular stick.

Is there a way round this that anyone can suggest ? I’m used to being able to print out whole pages that don’t appear on the screen, but the file system program doesn’t show this -

MTIA,

John

You could use the tree command see the structure of drive contents.

Could you expand that for this old codger !

Are you suggesting using Terminal in some way ?

Thanks,

John

EDIT just done this -

sudo apt update
sudo apt install tree

so I guess I’m heading in the right direction ?

Hi John :slightly_smiling_face:

Yes — the suggestion means using Terminal, but don’t worry, I’ll explain it step-by-step.

This method will create a full list of everything on the memory stick and save it to a file you can print.

Step 1 – Open Terminal

Press:

Ctrl + Alt + T

A small window with text will open.

Step 2 – Install the “tree” tool (only once)

Type this and press Enter:

sudo apt install tree

It may ask for your password — type it and press Enter.

Step 3 – Find your memory stick

Plug in the stick and open it in Files.
Look at the left side — you’ll see its name (for example: “KINGSTON” or similar).

Usually it is mounted under:

/media/your-username/

Step 4 – Create the inventory list

In Terminal, type:

tree /media/your-username/NAME_OF_STICK > inventory.txt

(Replace NAME_OF_STICK with the actual name.)

Press Enter.


Step 5 – Open the list

Now type:

gedit inventory.txt

You will see a complete list of all folders and files.
You can then print it like any normal document.


This way, you don’t need screenshots at all — everything will be neatly listed in one printable file.

If you’d like, tell me what the stick is called and I’ll write the exact command for you :slightly_smiling_face:

3 Likes

Thanks for your offer.

The memory stick is called FLASH DRIVE

I’ve tried a couple of times but got nowhere. First lesson was how to cope with spaces in the name.

Then how to get the path - at first all I got seemed to show the stick path was Home/FLASH_DRIVE. But opening the ‘Files’ after I’d connected the stick showed its path to be Computer/media/john/FLASH DRIVE.

So feel that the old grey cells have learnt new lessons !

John

1 Like

Latest try.

Any thoughts ?

John

If your USB is labeled FLASH DRIVE, you will need to reference it like this to deal with the space in it’s name:

tree /media/john/‘FLASH DRIVE’ > inventory.txt
gedit inventory.txt
1 Like

Thanks aljames, but I got the same result - error opening dir.

John

Double check your absolute path to FLASH DISK

You can right-click on the mounted USB in the left-nav of your file manager to see it’s path

Thanks, but no progress. Path seems OK.

John

Let’s try this again. I just ran this on an Ubuntu Live USB ISO and worked.

cd ~
tree -a /media/john/'FLASH DRIVE' > ~/inspection.txt
less inspection.txt

Throwing in the -a option to get “all” including hidden files & hidden directories if any. There are on an ISO, you may have some too.

Now, pg dn & pg up should scroll by pages or you can simply mouse scroll to the bottom.

Using less in case you don’t have gedit on your system. ‘q’ key gets you out of less.

1 Like

If grey1beard copy-and-pasted that, I can understand why there are problems. Look carefully at the quotes. Those are some kind of typographic quotes and the shell is quite particular about what kind of quotes it wants. These (') are fine and so are these ("). But these (`) aren’t (they actually mean command substitution) nor are these (´) or these (‘) or any of the many others that can be found in Unicode. The shell wants codepoint U+0022 or U+0027. On a US-keyboard you should get the right quotes by hitting the second key to the left of the enter key in the middle row of the main keyfield.

2 Likes

Thanks @hdd-gehrke I don’t know why, but my iPhone characters do not always come through as “good for code”. Another problem character is a double-dash presents as a single wide dash.

If I do this:

—dry-run

I typed a double-dash but as you can see the characters are not right.

I should know better than suggesting code or command on this thing :slight_smile:

My later reply was from my desktop, all good there.

Another thing you can try to get the right path to the flash drive is command completion. You use the tabulator key for that.
Just type

tree -a /media/john/FLA

and hit the tabulator key. Unless there’s something else starting with ‘FLA’ in that directory the shell should complete that to tree -a /media/john/FLASH\ DRIVE (the Backslash is another way to do quoting; it takes away the special meaning of the next following character; space characters have the special meaning ‘word separator’ and putting a backslash before a space neutralizes that so the space becomes just another part of the name).

BTW, instead of tree – which gives a nice but not all that informative view of the contents – I’d use ls with the option --long --recursive or -lR (those mean the same thing, the first variant is easier to understand, the second is faster to type). This gives you a lot more information, not just the directory structure and the files in there but also permissions, ownership, size, and modification date for each file.

ls -lR /media/john/FLASH\ DRIVE > ~/inventory.txt
1 Like

Thanks all for your thoughts on my behalf.

There will be a short delay, as I have a BBQ to clean after a week without power (ice storm!), so you might guess what that entails.

Please bare in mind that my alternative route is to produce a print out of screen shots, albeit with some cut and pastes, but in the long run that may be quicker for my needs.

However, I’m learning greatly through this inquiry, and hopefully others may benefit.

Thanks again,

John

This topic was automatically closed after 30 days. New replies are no longer allowed.