Why does Automator not see new files in subdirectories on a Flash Drive?

I've created an automator app to find all the csv files on a flash drive, then modify and copy those files to a directory on the hard disk of my MAC. The automator app uses a shell script to compare the files found on the flash drive to those already on the hard disk, and it only copies the files that do not already exist in the destination directory.

For the first 21 files (they are numbered) this worked just fine, but now files 22-30 do not get copied over to the hdd. After some debug, I found that automator is not seeing the complete list of csv files that exist on the flash drive.

The way things are supposed to work is, I insert the flash drive into the MAC SD card slot. Then I drag the icon for the flash drive on top of the icon for the automator app. The automator app steps are: “Get Folder Contents” (‘Repeat for each subfolder found’ is checked), followed by “Filter Finder Items” (which looks for files with the extension “.csv”). Then that list of files passes to my Shell Script (which compares the names of the files it receives to the names of the files in the destination directory, and acts on those files that do not exist in the destination directory).

With debug I have found the problem happens before the Shell Script, the list of files passed from “Filter Finder Items” does not include the newest files on the flash drive.

Through another step of debug I found that if I open one of the csv files using Numbers (while the csv file is still on the flash drive), then close the file (no editing or saving involved), then when I drag the Flash Drive icon onto the automator app icon, THAT csv file which I have just opened DOES get passed to the script and the file ends up in the destination directory.

When I was developing this automator app the first 21 files already existed on the flash drive. Everything worked fine. A week later, the new files were added to the flash drive (by an external, non-MAC device), and now for some reason the MAC files system (or at least automator) does not “see” the new files.

I have some ideas as to how to fix this, but I am wondering if there is some caching feature of the Flash Drive that might be intervening, or some other MAC OS idiosyncrasy that I am missing.

Power-down and rebooting the MAC did not fix it.

Any thoughts on this? thanks, michael.


Solution 1:

"The Filter Finder Items action uses Spotlight. Having success after using an item with Numbers.app would suggest that the (newer) external files have not been indexed (yet)."

Thanks!! I modified the Automator app to remove the "Filter Finder Items" action (I put this functionality into the Shell Script) so now I have: “Get Folder Contents” (‘Repeat for each subfolder found’ is checked), followed by a Shell Script (which compares the names of the files on the flash drive to the names of the files in the destination directory, and acts on those files that do not exist in the destination directory).

And this works just fine, no files are left out.