Jump to content
Due to a large amount of spamers, accounts will now have to be approved by the Admins so please be patient. ×
IGNORED

generating directory contents from Pi (Linux)


Recommended Posts

Wondering if anyone knows how to generate a text file within linux that list the contents of a directory ? My use is for generating a list of roms within a directory in a Retropie install (linux)

 

Cheers,

Jed

Link to comment
Share on other sites

For a [directory] and all sub directories into [filename]:

 

find [directory] -type f > [filename]

 

or for a single directory just (That's a lower case LS) but it'll include the sub directory names:

 

ls [directory] > [filename]

 

- - - Updated - - -

 

You could also use the -maxdepth flag to find:

find [directory] -maxdepth 1 -type f > [filename]

 

Using two >> will append to filename instead of overwriting it.

 

- - - Updated - - -

 

If you want to find just the zip files in a particular directory:

 

find [directory] -type f -iname \*.zip > [filename]

If you want to strip the .zip off the filename:

 

find [directory] -type f -iname \*.zip | sed 's/\.zip//' > [filename]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...