0

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.

  • 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). – red_menace Jan 21 at 16:14
  • Thanks. So I assume that it is the "Get Folder Contents" that uses Spotlight and is failing to see (and pass) the new files to "Filter Finder Items". I tried to replicate the Get Folder Contents with my shell script, but I run into problems because the .Trashes directory is not accessible. I get find /Volumes/MJB_KEY_256 -name "*.csv" find: /Volumes/MJB_KEY_256/.Trashes: Operation not permitted when I try find in the shell. Google search examples for how to skip the dot-directory do not work for me – ObjCLearner Jan 22 at 4:16
  • It would be the Filter Finder Items action - the various filter terms are usually extracted from the Spotlight database, so if there isn't one the term may not be there to match. – red_menace Jan 22 at 5:38
  • Yes, thanks, I verified that was the case, and used your original comment as the answer. You have been most helpful, thanks! – ObjCLearner Jan 22 at 19:09
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.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .