With Bash
When you pass arguments to bash using -c
, then the argument just after -c
must contain the whole thing you want bash to run. To illustrate, assuming NONEXISTENT does not exist:
$ bash -c ls NONEXISTENT
Will just ls all the files in your directory, no error.
$ bash -c 'ls NONEXISTENT'
Will launch ls NONEXISTENT
and will give an error.
So your arg
list must be built something like this:
['-c', 'find /home/user/directory \( -name "*.mp4" -o -name "*.zip" \) ! \( -name "tokeep.mp4" -o -name "tokeep2.mp4" \) -ls -delete']
The argument that comes after -c
is the whole command you want bash to run.
Without Bash
But as I've said in the comment, I do not see anything in your use of find
that should require you pass it to bash. So you could reduce your arg
list to just what you want find
to execute and spawn
find directly. If you decide to do this, you must not quote the arguments you pass to find. So "*.mp4"
must become *.mp4
(remove the quotes), \(
must become (
. The presence of the quotes and the slashes are just for bash. If you no longer use bash, then you must remove them. For instance, this:
'\\(', '-name', '"*.mp4"', '-o', '-name', '"*.zip"', '\\)', '!', '\\('
must become:
'(', '-name', '*.mp4', '-o', '-name', '*.zip', ')', '!', '('
and the same transformation must be applied to the rest of your arguments.