2

I have a script that moves files to Trash, but I work with tens of thousands of files so I need it to do fast. Current script gets Finder stuck and I need to relaunch Finder every time I use the script.

set source_folder to POSIX path of (path to pictures folder) & "4K Stogram"

do shell script "/usr/bin/find " & quoted form of source_folder & " -type f -exec /bin/mv {} ~/.Trash \\;"

display notification "All images were processed." with title "New" sound name "Glass.aiff"
tell me to quit

Wouldn't the shell script's 'rm -f' command make it faster? How the script should look like if yes? I don't need those files in Trash anyway, I delete them right after the script finishes the job.

Vassili Bagrov
  • 71
  • 1
  • 10

2 Answers2

2

Add the -delete option to the find command.

Like this:

set source_folder to POSIX path of (path to pictures folder) & "4K Stogram"
do shell script "/usr/bin/find " & (quoted form of source_folder) & " -type f -delete"
jackjr300
  • 7,111
  • 2
  • 15
  • 25
0

You should be able to pipe your find results to the rm command. Understand that although rm should be faster, it is permanent. Be sure that your code is correct before invoking it.

Community
  • 1
  • 1
Craig Smith
  • 1,063
  • 2
  • 11
  • 21