is it possible to get a negative search result from "find " to a log file? if not then compare the content of Destination to the input of the first dialog (theVideos) and write to log?
If I hit cancel in the second dialog it returns to the first dialog, how can I avoid that?
how do I get the choosen folder (instead to the whole path) to text so I can put it in Progress Bar?
The script is fully functional but it would be nice to add/correct these things…
Its not possible for you guys to run the full script unless the Progress bar is in this path: (((path to scripts folder) as text) & “Lib:BP Progress Bar Controller.scpt”) or just leave it out…
Here is what I have so far:
property theSDirectory : "/Volumes"
property noSearch : "/Volumes/Macintosh HD"
set theVideos to text returned of (display dialog "Type the name separated with a ',' " default answer "" buttons {"cancel", "find"} cancel button "cancel" default button 2)
if theVideos is false then return
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 & "*") & " -iregex " & quoted form of regex)
if master_list is {} then
display dialog "no Videos found " buttons {"OK"} default button 1
end if
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 "Copying: " & filename & " -> " & (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
end
Thanks in advance,
Peter