title: How to recursively traverse a directory tree and find only files?
body: <p>I am working on a <code>scp</code> call to download a folder present on a remote system. Downloaded folder has subfolders and within these subfolders there are a bunch of files which I want to pass as arguments to a python script like this:</p>
  
  <pre><code>scp -r researcher@192.168.150.4:SomeName/SomeNameElse/$folder_name/ $folder_name/
  echo "File downloaded successfully"
  echo "Running BD scanner"
  for d in $folder_name/*; do
          if [[ -d $d ]]; then
                  echo "It is a directory"
          elif [[ -f $d ]]; then
                  echo "It is a file"
                  echo "Running the scanner :"
                   python bd_scanner_new.py /home/nsadmin/Some/bash_script_run_files/$d
          else
                  echo "$d is invalid file"
                  exit 1
          fi
  done
  </code></pre>
  
  <p>I have added the logic to find if there are any directories and excluding them.  However, I don't traverse down those directories recursively.</p>
  
  <p>Partial results below:</p>
  
  <pre><code>File downloaded succesfully
  Running BD scanner
  It is a directory
  It is a directory
  It is a directory
  Exiting
  </code></pre>
  
  <p>I want to improve this code so that it traverses all directories and picks up all files. Please help me with any suggestions.</p>