I’m working on a script to find files but i could really use some help with the following:
I would like to also exclude all hidden files and directories
write to log if items are not found (just the name)
is anyone familiar with the new progress option in Yosemite’s Applescript ? its supposed to give a nice progress bar…
this is what I have soo far:
property theSDirectory : "/Volumes"
property noSearch : "Macintosh HD"
set theVideos to text returned of (display dialog "looking for video?" default answer "" buttons {"ok", "cancel"} cancel button "cancel" default button 1)
set oldDels to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set theVideolist to every text item of theVideos
set AppleScript's text item delimiters to "|"
set theVideolist to theVideolist as string
set AppleScript's text item delimiters to oldDels
set theLog to (do shell script "touch " & "~/Desktop/notFound.txt ")
set regex to theSDirectory & "/.*(" & theVideolist & ").*"
set master_list to paragraphs of (do shell script "/usr/bin/find -E " & quoted form of theSDirectory & " -name " & quoted form of noSearch & " -prune " & " -o " & " -iregex " & quoted form of regex & " -print ")
thanks Stefan
one question though: I already have a exclude directory called “MacintoshHD” so whats the right syntax for also putting yours in? As you can see I used -prune so it won’t traverse into it(only needs to look for files in external mounts) and does not show up in the list to choose from which is in the second part of the script. thats why I used -print. So basicly don’t find/traverse into directories and don’t list
and how do I get not found into the created log?
hi stefan
i tried your solution but it still gives me files starting with .
here is the full script, i changed -name to -path as it make more sense (thanks for that)
here is the full script:
property theSDirectory : "/Volumes"
property noSearch : "/Volumes/Macintosh HD"
--property Destination : "/Users/Peter/Desktop/dest"
set theVideos to text returned of (display dialog "looking for video?" default answer "" buttons {"ok", "cancel"} cancel button "cancel" default button 1)
set oldDels to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set theVideolist to every text item of theVideos
set AppleScript's text item delimiters to "|"
set theVideolist to theVideolist as string
set AppleScript's text item delimiters to oldDels
set theLog to (do shell script "touch " & "~/Desktop/notFound.txt ")
set regex to theSDirectory & "/.*(" & theVideolist & ").*"
set master_list to paragraphs of (do shell script "/usr/bin/find -E " & quoted form of theSDirectory & " -type f ! -name '.*' " & " -path " & quoted form of noSearch & " -prune " & " -o " & " -iregex " & quoted form of regex & " -print ")
set selected to choose from list master_list ¬
with prompt "Please select:" with multiple selections allowed
set listSize to (count of selected) as string
if selected is false then return
set Destination to choose folder with prompt "Choose your Destination:"
set loopCount to "0" as number
set ProgressBar to load script alias (((path to scripts folder) as text) & "Lib:BP Progress Bar Controller.scpt")
tell ProgressBar
initialize("copy selected videos")
barberPole(true)
setStatusTop to "copying..."
repeat with aPath in selected
set AppleScript's text item delimiters to "/"
set filename to last text item of aPath
set AppleScript's text item delimiters to ""
set loopCount to ((loopCount) + 1)
setMax to listSize
setStatusTop to "moving: " & filename & " --> " & quoted form of (POSIX path of Destination)
setStatusBottom to "Number of Items: " & loopCount & " of " & listSize
do shell script "/bin/cp " & quoted form of aPath & space & quoted form of (POSIX path of Destination)
increase by 1
end repeat
tell ProgressBar to quit
display dialog "Videos are copied" buttons {"OK"} default button 1
do shell script "open " & quoted form of (POSIX path of Destination)
end tell