HELP: Copy contents of Saved Search to another drive

Hello, I’m totally new to automation and am trying to learn.
My first task I’d like to automate is copying all of my Final Cut Pro X Library files found on one drive to my boot drive. These small files that end in .fcpbundle are in several different places on my main video editing hard drive. To gather them, I created a saved search that looks on my drive for the file extension .fcpbundle.

Now that I have all the files gathered. I would like to automatically have the files in this saved search query be copied to a “FCPX Library Backups” folder which will live in the Movies folder of my Macintosh HD.

Ideally I would like this task to be run once a day around 5PM CST. As a bonus, if I could hit a button that launches this task that would be super helpful. I would be grateful for any help in creating this. My goal is to understand the task so I can start to automate more of the “file management” tasks I do in my video editing work.

Thanks!,

Ben

The saved search is useful for you to use, but in terms of automation there are command line options that do the same.

Take a look at Copy all files with a certain extension from all subdirectories.

For scheduling there are many options - How can I get a script to run every day on Mac OS X?. I mainly make use of at for ad hoc scheduling and actually use Keyboard Maestro to manage my regular schedule as I then have one place to look for my script based and non-script based scheduled automations.

Hope that helps.

Thanks for the resources. Admittedly, this is over my head, but I am reading it and giving it a shot. I did run the find command from the first link you provided and got terminal feedback: Permission Denied.

I will continue looking into this and see if I can make sense of it.

Ben

So when I use the following Terminal command:

find /Volumes/BENS_BCP_2 . -name *.fcpbundle -exec cp -R {} /Users/brodbb/Movies/BCP\ -\ FCPX\ Library\ Backups ;

Terminal searches my Macintosh HD for .fcpbundle files. (cp -R is used as .fcpbundle is a directory) and copies to the desired location. That said, I’m trying to copy .fcpbundle files from the external drive BENS_BCP_2 not my Macintosh HD

I have a screenshot attached here depicting the macOS Saved Search that I’m attempting to emulate. This saved search provides me exactly the contents I want to automatically copy to my main drive.

I need help understanding how to tell Terminal to exclude .fcpbundles that include “CDT”, “CST”, “PDT” and “EDT” in their names.

Also, I need help understanding how to make Terminal copy the .fcpbundles that reside on my drive “BENS_BCP_2” as the command at the top of this post actually copies .fcpbundles that are on my Macintosh_HD (which is not what I want).

As I mentioned in my original post, I’m brand new to all of this, so any help would be greatly appreciated.

Thanks!

Ben

To exclude files the you would need to look at changing your match criteria to exclude those files. Find uses ! as not. Take a look at How to ignore certain filenames using "find"? for a use case/example.

In regards to the permissions error, all I can suggest is that you look at the permissions on the files and the directory you are intending to copy to. Are you (as the logged in terminal user), the owner of the files?

I’d try a test case of trying to copy just one file, look at the permissions on the directory. You can use ls -l in a directory to view the permissions on the files and sub-directories. You can look up online if needs be to find out more information on how to read and make sense of the permissions it shows.

I was able to figure out the permissions issue but the command still runs on the wrong drive. I think I can handle figuring out how to ignore the text I don’t want in my results. The big issue I’m still having is getting this to only run and find files on my external drive. Any ideas on how to make this happen?

Thanks,

Ben

Success #1
I was able to properly filter the find command as you mentioned with (!).
I was also able to properly target the command to my external drive.

The command that worked for me was:
cd /Volumes/BENS_BCP_2 ;find /Volumes/BENS_BCP_2 . ! -path “*CDT.fcpbundle” ! -path “*CST.fcpbundle” ! -path “*PDT.fcpbundle” ! -path *PST.fcpbundle ! -path “*EDT.fcpbundle” -name *.fcpbundle -exec cp -R {} /Users/MyUser/Movies/BCP\ -\ FCPX\ Library\ Backups ;

I took this into Automator, made a new Application and pasted the above commands into the Run Shell Script action. I saved the Application and it backs up my FCPX Libraries with the click of a button!

That said, when I run the Application, after completing successfully the app gives an error (see the attached screenshot)

Is there a way for me to have Automator prevent this error message from appearing? The end user (me) currently has to dismiss the error message by clicking ‘OK’.

Thoughts?

Thanks for all your help in getting me this far!

Ben

You probably want to try and put the output into a file in case you do need to to reference it. Have a look through this thread at the general discussion and for an example that writes the script output to a file.

https://macscripter.net/viewtopic.php?id=5284

I tend to have really weird errors in Automator when running shell scripts that don’t exist when I run something in the terminal.
I would throw your

cd /Volumes/BENS_BCP_2 ;find /Volumes/BENS_BCP_2 . ! -path “*CDT.fcpbundle” ! -path “*CST.fcpbundle” ! -path “*PDT.fcpbundle” ! -path *PST.fcpbundle ! -path “*EDT.fcpbundle” -name *.fcpbundle -exec cp -R {} /Users/MyUser/Movies/BCP\ -\ FCPX\ Library\ Backups ;

into a file call it copyFCP.sh. Put #!/bin/sh at the top.

Then, If you want it to be clickable, you can remove .sh, and run chmod 755 copyFCP. otherwise, you can just call bash copyFCP.sh and it will run.