I am trying to create a Python script that would search recursively for a specific file extension and run a command on each individual file that is found. I did this in bash using a for loop that looked like this:
Code:
for files in $(find -type f -name "*.001")
do
ftkimager $files --verify >> images.txt
done
ftkimager is a command line program for imaging hard drives. The script looks for .001 files, verifies against a MD5 hash, and places the results into images.txt
I wanted to let the user input a starting directory, so I added that to my Python script and use the subprocess module to run shell commands and execute ftkimager. Here is what I have so far for the Python script:
Code:
import subprocess
source = raw_input ("Enter the Path \n")
for files in subprocess.call (['find '+source+' -type f -name "*.001"], shell=True)
subprocess.call (['ftkimager '+source' --verify'], shell=True)
When run, I get an invalid syntax error on the for loop. Since the other parts work when I comment out the for statement, I'm assuming I'm doing the for loop incorrectly but I don't know how to get the command to work properly. Does anyone know how to fix this, or (if possible) do what I want to do in a better way?