Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    simple shell script for batch copying

    hey there y'all!

    I'm new to the forum, so hello.

    I'm looking for what I imagine would be a simple script, but I'm totally new to scripting. I appreciate any help you can offer.

    I'm looking to grab all wav files that are in ANY directory called "export". All of these wav files should be copied to another folder.

    any ideas?


  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Hi and welcome.

    This oneliner is not perfect, it will break on strange filenames with e.g. spaces.
    It also assumes, that wav files have the suffix .wav, which might not always be the case.
    These are left as an exercise to the reader

    Replace <DEST_DIR> with the directory, that shall contain the wav files after the copy.
    Also it is beneficial to change the startdirectory from / to a more specific place, as there are for sure no wavs in /bin /var, /etc, etc
    find / -path "*/export/*.wav" -exec cp -b {} <DEST_DIR> \;
    Oops, if the start dir should be /, then there needs to be an exclude for <DEST_DIR>, otherwise there might be an infinitive loop.
    Last edited by Irithori; 09-10-2012 at 10:31 AM.
    You must always face the curtain with a bow.

Posting Permissions

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