need some help with finalizing my script

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

Hi,

positive and negative search result is not possible with a single shell call.
A Spotlight search filtering video files is probably much faster.

This is a version with some improvements using Spotlight but without the negative result and destination compare.
Of course it assumes that all volumes are indexed by Spotlight


property excludeVolumeList : {"Macintosh HD"}

set theVolumes to paragraphs of (do shell script "/bin/ls /Volumes") -- get volume names

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)
set {tid, text item delimiters} to {text item delimiters, ","}
set nameList to text items of theVideos

set FSNameList to {}
repeat with aName in nameList -- create SpotLight predicate for each name
	set end of FSNameList to "kMDItemFSName == *" & aName & "*"
end repeat
set text item delimiters to " || " -- "OR" the list
set searchCriteria to "(" & (FSNameList as text) & ")"

set text item delimiters to tid
set masterList to {}
repeat with aVolume in theVolumes
	if excludeVolumeList does not contain (contents of aVolume) then
		set foundVideos to paragraphs of (do shell script "/usr/bin/mdfind -onlyin " & quoted form of ("/Volumes/" & aVolume) & " 'kMDItemContentTypeTree == public.movie && " & searchCriteria & "'")
		set masterList to masterList & foundVideos
	end if
end repeat

if master_list is {} then
	display dialog "no Videos found " buttons {"OK"} default button 1
	return
end if
set selected to choose from list master_list ¬
	with prompt "Please select:" with multiple selections allowed
if selected is false then return
set listSize to (count of selected) as string

set Destination to POSIX path of (choose folder with prompt "Choose your Destination:")

set loopCount to 0
set ProgressBar to load script alias ((path to scripts folder as text) & "Lib:BP Progress Bar Controller.scpt")
set tid to text item delimiters
set text item delimiters to "/"
set folderName to text item -2 of Destination
tell ProgressBar
	initialize("copy selected videos")
	barberPole(true)
	setStatusTop to "copying..."
end tell
repeat with aPath in selected
	set filename to last text item of aPath
	set loopCount to loopCount + 1
	tell ProgressBar
		setMax to listSize
		setStatusTop to "Copying: " & filename & " -> " & folderName
		setStatusBottom to "Number of Items: " & loopCount & " of " & listSize
	end tell
	do shell script "/bin/cp " & quoted form of aPath & space & quoted form of Destination
	tell ProgressBar to increase by 1
end repeat
set text item delimiters to tid
tell ProgressBar to quit
display dialog (loopCount as text) & " Videos are copied" buttons {"OK"} default button 1
do shell script "open " & quoted form of Destination

thanks Stefan but its a NAS and not indexed by spotlight…