I’m writing a little tool that removes files from a selected device. In order to provide meaningful feedback I have set it up so first the tool finds all the files that will be deleted then later presents a progress bar as each file is individually deleted.
tell application "Finder" to set theItems to every item of sourceFolder
--Iterate through the items in sourceFolder
repeat
tell application "Finder"
set countedNumber to countedNumber + 1
set nextItem to first item of theItems
if ((class of nextItem) is folder) then
--The item is a folder, so add its files to the end of the array
set theItems to theItems & every item of nextItem
else
set theItemPath to nextItem as alias
set theItemPaths to theItemPaths & theItemPath
-- convert alias to POSIX
set posixItemPath to (the POSIX path of theItemPath)
-- add POSIX path to the list
set thePOSIXItemPaths to thePOSIXItemPaths & posixItemPath
end if
if ((count of theItems) is 1) then
exit repeat
else
set theItems to items 2 thru (count of theItems) of theItems
end if
end tell
end repeat
The code above does not find invisible items on the device, some files and folders starting with a period, can someone suggest how I can get invisible files and folders to work in the above routine?