does any one now how to clear the search history in sidebar?
This is really dangerous rubbish in my view. What you see as the Today/Yesterday/Last Week 'folder' are in fact smart queries looking at the document metadata in the filesystem and showing you the real files. If you delete them, they're gone. That's it, end of. On the other hand if you put them back where they belong they'll still have the same date in the file metadata and will still show up in the Today/Yesterday/Past Week searches.Open "Today" or "Yesterday" or "Past Week", select All and put in trash, then select All, and "Put Back" using right click menu. If "Put Back" is not visible (depend of kind of file ), select file by file or group of files. This method work also for search and Smart Folder. REMEMBER to "Put Back" to recover the files in the original position (the files are real deleted). In history are not recovered
This is really dangerous rubbish in my view. What you see as the Today/Yesterday/Last Week 'folder' are in fact smart queries looking at the document metadata in the filesystem and showing you the real files. If you delete them, they're gone. That's it, end of. On the other hand if you put them back where they belong they'll still have the same date in the file metadata and will still show up in the Today/Yesterday/Past Week searches.
The only way I can think of is to modify the datestamp within the document metadata, which must be possible as the system does that every time you open the file, but I suspect you need to be an experience OS X developer to make something that can do this.
I am sorry, mat this method works.Tray to see !!. Some time fail if the file is protected but I an not understand why. With the same kind of file, the same protection, one is cleared (from ,for instance, "Today") and the other not. I must to investigate
rm -rf "/Volumes/extfat32volume/._filename"
set originalFile to choose file with prompt "Choose a document to clear from sidebar history:"
set originalPOSIXFilePath to POSIX path of originalFile
--Set the name of your FAT32 volume in the quotes on the next line
set otherDisk to "NO NAME"
tell application "Finder"
set originalFilePath to container of originalFile as text
copy file originalFile to disk otherDisk
end tell
set originalFileName to name of (info for originalFile)
set destinationFullPath to otherDisk & ":" & originalFileName
set destinationMDFullPath to otherDisk & ":._" & originalFileName
set copiedFile to alias destinationFullPath
set copiedFileMD to alias destinationMDFullPath
tell application "Finder"
delete originalFile
delete copiedFileMD
copy file copiedFile to alias originalFilePath
delete copiedFile
end tell
delay 0.5
--last part modifies the POSIX last access time to complete the job
do shell script "touch -a -t 200901010715 " & originalPOSIXFilePath
on hide_item(fileToProcess)
set posixPath to POSIX path of fileToProcess
do shell script "touch -a -t 200901010730 " & "'" & posixPath & "'"
do shell script "gzip " & "'" & posixPath & "'"
do shell script "gzip -d " & "'" & posixPath & ".gz'"
end hide_item
on run
set anItem to choose file with prompt "Choose a document to clear from sidebar history:"
hide_item(anItem)
end run
on open itemsToHide
repeat with anItem in itemsToHide
hide_item(anItem)
end repeat
end open
on hide_item(fileToProcess)
set posixPath to replaceChar(POSIX path of fileToProcess, "\"", "\\\"")
do shell script "touch -a -t 200901010730 " & "\"" & posixPath & "\""
do shell script "ditto --norsrc \"" & posixPath & "\" tmpfile.jpg && mv tmpfile.jpg " & "\"" & posixPath & "\""
end hide_item
on replaceChar(theString, oldChar, newChar)
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to oldChar
set theArray to every text item of theString
set theNewString to ""
repeat with i from 1 to length of theArray
set stringPart to item i of theArray
set theNewString to theNewString & stringPart
if i is less than length of theArray then set theNewString to theNewString & newChar
end repeat
return theNewString
end replaceChar
on run
set anItem to choose file with prompt "Choose a document to clear from sidebar history:" without invisibles
hide_item(anItem)
end run
on open itemsToHide
repeat with anItem in itemsToHide
hide_item(anItem)
end repeat
end open
--Main handler for the script.
on hideItem(pathAlias)
--Get the path to use in the shell command from the alias of the file.
set posixPath to POSIX path of pathAlias
set quotedPosixPath to quoted form of posixPath
--Checks that the path is to a file and not a directory and proceeds.
if isPOSIXDirectoryPath(posixPath) is false then
do shell script "touch -a -t 200901010730 " & quotedPosixPath & " && ditto --norsrc " & quotedPosixPath & " tmpfile.jpg && mv tmpfile.jpg " & quotedPosixPath
else
do shell script "touch -a -t 200901010730 " & quotedPosixPath & " && ditto --norsrc " & quotedPosixPath & " tmpfile && rm -rf " & quotedPosixPath & " && mv tmpfile " & quotedPosixPath
end if
end hideItem
-- Checks whether the POSIX path given points to a directory or a file. True if directory.
on isPOSIXDirectoryPath(thePath)
if last character of thePath is "/" then
set theResult to true
else
set theResult to false
end if
return theResult
end isPOSIXDirectoryPath
-- Displays a prompt to select a file in the event that the script is double-clicked.
on run
set anItem to choose file with prompt "Choose a document to clear from sidebar history:" without invisibles
hideItem(anItem)
end run
-- Provides droplet functionality.
on open itemsToHide
repeat with anItem in itemsToHide
hideItem(anItem)
end repeat
end open