Results 1 to 5 of 5

Thread: Need shell script for processing multiple files

  1. #1
    Join Date
    Jun 2008
    Location
    Kln, Deutschland
    Posts
    1,054

    Default Need shell script for processing multiple files

    I'm trying to get a list of .bsp files from a long list of .pk3 (.zip) files.

    I can do that with one single file as in this example -

    Code:
    zipinfo filename.pk3 | grep .bsp
    But sadly zipinfo doesn't like using the wildcard for in_file_name.

    I need to be able to do something like this in a bash script -

    Code:
    for each <filename.pk3>
      do
          zipinfo <filename> | grep .bsp >> maps.txt
      end
    I have no idea how to do that though, any help appreciated
    HP dv6645, Nvidia 8400m-gs, KDE 4.

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: Need shell script for processing multiple files

    Code:
    for f in *.pk3
    do
      zipinfo $f | grep '\.bsp'
    done > maps.txt

  3. #3
    Join Date
    Jun 2008
    Location
    Kln, Deutschland
    Posts
    1,054

    Default Re: Need shell script for processing multiple files

    Fantastic, thanks a million
    HP dv6645, Nvidia 8400m-gs, KDE 4.

  4. #4
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: Need shell script for processing multiple files

    Actually even I forget this sometimes but you should write:

    zipinfo "$f" ...

    just in case the filename contains whitespace.

  5. #5

    Default Re: Need shell script for processing multiple files

    Use the find command. For example:

    Code:
    find . -name "*.pk3" -exec zipinfo -1 {} \;
    NOTE: The space before the backslash semicolon is required.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •