I pasted together an Applescript to write a small file to each folder in a list of folders. This way we should be able to see what folders spotlight is indexing.
(*
Place marker files in a list of folders so we can "see" what spotlight does.
Author: rccharles
For testing, run in the Script Editor.
1) Click on the Event Log tab to see the output from the log statement
2) Click on Run
For running shell commands see:
http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
Copyright 2013 rccharles
GNU General Public License
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
For a copy of the GNU General Public License see <http://www.gnu.org/licenses/>.
*)
on run
global firstRunning
-- Names of the folders in which to write a marker file. Use Unix names path.
-- find -x / -type d -maxdepth 1
set folderList to ¬
{¬
"~/spotNoWrite", ¬
"~/Desktop/Bethesda", ¬
"~/sNoneForSpot", ¬
"~/Desktop"}
-- Write a message into the applescript editor event log.
log " --- Starting on " & ((current date) as string) & " --- "
log "folderList = " & folderList
set actualCd to do shell script "cd ~;pwd"
log "actualCd = " & actualCd
repeat with theFile in folderList
log "theFile = " & theFile
set firstRunning to ""
set expandPath to alterString(theFile, "~", actualCd)
log "expandPath = " & expandPath
debug("SpotlightIndexedData ", expandPath, "SpotlightIndexedFolder")
end repeat
end run
-- ---------------------------------------------
(*
Create or add to a log file
based on log by James Reynolds, 12.18.2000, University of Utah
called recursively.
input:
text string message writen to file
expanded posix path to file. ( no ~ in string )
file name
*)
on debug(theMessage, thePath, theFileName)
global firstRunning
local theSize, startupDiskName, fileToLog, fileReference, appPath, changedPerms
set lineEnd to ASCII character 10
log "==> debug called"
log " theMessage = " & theMessage & " class is " & class of theMessage
log " thePath = " & thePath
log " theFileName = " & theFileName
set savePerms to ""
set imbedPath to theFileName & " on " & alterString(thePath, "/", "-") & ".txt"
log "imbedPath = " & imbedPath
set unixPathToLog to (thePath & "/" & imbedPath)
log "unixPathToLog = " & unixPathToLog
set fileToLog to POSIX file unixPathToLog as string
log "fileToLog = " & fileToLog
-- Can we write to this folder?
try
set fileReference to (open for access file fileToLog ¬
with write permission)
on error errorMsg
log "got error >" & errorMsg & "< "
-- log an attempted permission change on a folder
set permFileName to "spewChangePermissionList"
log "permFileName = " & permFileName & " class is " & permFileName
-- check for recursive looping
if theFileName is equal to permFileName then
display dialog "This is bad. Looks like a loop. thePath = " & thePath ¬
& " theFileName = " & theFileName
return
end if
set permFolder to path to home folder
set unixPermFolder to POSIX path of permFolder
log "unixPermFolder = " & unixPermFolder
set permList to do shell script "ls -ld " & quoted form of thePath
log "permList = " & permList & " class is " & class of permList
set priorRunning to firstRunning -- probably "" anyway.
-- keep track of the folders we plan on changing
debug(permList, unixPermFolder, permFileName)
log "... from debug"
set firstRunning to priorRunning
-- perserve permissions.
set savePerms to do shell script "stat -f \"%Lp\" " & quoted form of thePath
-- fix permissions if we can.
try
set cmd to "chmod a+wx " & quoted form of thePath
log "cmd = " & cmd
set fromUnix to do shell script cmd with administrator privileges
on error errMsg
log "chmod error...>" & errMsg & "< on " & thePath
display dialog "Could not change permissions. >" & errorMsg & ¬
"< on " & thePath ¬
giving up after 20
return
end try
set fileReference to (open for access file fileToLog ¬
with write permission)
end try
log "firstRunning = " & firstRunning
set theSize to (get eof fileReference)
log "theSize = " & theSize
if firstRunning = "" then
-- New file to create?
if theSize is equal to 0 then
appendToFile(fileReference, "New log created on " & ((current date) as string) & " " & lineEnd)
close access fileReference
try
-- file must be closed for finder to change creator type.
tell application "Finder"
-- TextWrangler
set the creator type of the file fileToLog ¬
to "!Rch"
end tell
on error errorMsg
display dialog "warning problem with setting creator type. >" & errorMsg & "< results for " & fileToLog giving up after 30
end try
set fileReference to (open for access file fileToLog ¬
with write permission)
end if
appendToFile(fileReference, " --- debug on " & ((current date) as string) & " --- " & lineEnd)
tell current application
set appPath to path to current application
end tell
appendToFile(fileReference, " --- current AppleScript is " & appPath & " ---" & lineEnd)
set firstRunning to "running"
end if
appendToFile(fileReference, theMessage & lineEnd)
close access fileReference
-- restore directory to what permsissions it had.
if savePerms is not equal to "" then
try
set cmd to "chmod " & savePerms & " " & quoted form of thePath
log "cmd = " & cmd
set fromUnix to do shell script cmd with administrator privileges
on error errMsg
log "chmod error on restoring file ...>" & errMsg & "< on " & thePath
display dialog "Could not change permissions on attempting retore. >" & errorMsg & ¬
"< on " & thePath ¬
giving up after 20
return
end try
end if
end debug
-- ------------------------------------------------------
on alterString(thisText, delim, replacement)
set resultList to {}
set {tid, my text item delimiters} to {my text item delimiters, delim}
try
set resultList to every text item of thisText
set text item delimiters to replacement
set resultString to resultList as string
set my text item delimiters to tid
on error
set my text item delimiters to tid
end try
return resultString
end alterString
-- ------------------------------------------------------
-- textToList was found here:
-- http://macscripter.net/viewtopic.php?id=15423
on textToList(thisText, delim)
set resultList to {}
set {tid, my text item delimiters} to {my text item delimiters, delim}
try
set resultList to every text item of thisText
set my text item delimiters to tid
on error
set my text item delimiters to tid
end try
return resultList
end textToList
-- ----------------------------------------------------------
on appendToFile(fileId, theData)
local theSize, writeWhere
log "--> class is " & class of theData
set theSize to (get eof fileId)
set writeWhere to theSize + 1 as integer
write theData to fileId starting at writeWhere as «class utf8»
end appendToFile