Announcement

Collapse
No announcement yet.

generating directory contents from Pi (Linux)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • generating directory contents from Pi (Linux)

    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

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

    Code:
    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:

    Code:
    ls [directory] > [filename]
    - - - Updated - - -

    You could also use the -maxdepth flag to find:
    Code:
    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:

    Code:
    find [directory] -type f -iname \*.zip > [filename]
    If you want to strip the .zip off the filename:

    Code:
    find [directory] -type f -iname \*.zip | sed 's/\.zip//' > [filename]
    Live on Twitch, when I can at random times | twitch.tv/ajfclark | You can vote for what machine I play, click here, follow my channel and type '!vote' in chat for details | Movember: mobro.co/ajfclark

    Comment


    • #3
      awesome reply. thanks

      Comment


      • #4
        You're welcome.
        Live on Twitch, when I can at random times | twitch.tv/ajfclark | You can vote for what machine I play, click here, follow my channel and type '!vote' in chat for details | Movember: mobro.co/ajfclark

        Comment

        Users Viewing Topic: 0 members and 1 (guests)
        Working...
        X