(*on my HD I have the following files:
/Library/Documentation/Help/VoiceOver.help/Contents/Resources/Dutch.lproj/pgs/10052.html
/Library/Documentation/Help/VoiceOver.help/Contents/Resources/English.lproj/pgs/10052.html
/Library/Documentation/Help/VoiceOver.help/Contents/Resources/French.lproj/pgs/10052.html
Why does this not find them?
Thanks
PS My aim is to list all the files with that name in the chosen folder
*)
set theFolder to choose folder -- and I choose the Library folder
set usrChc to "10052.html"
set theFiles to paragraphs of (do shell script "mdfind -onlyin " & quoted form of (theFolder as text) & " \"kMDItemFSName == " & quoted form of (usrChc as text) & "\"")
Here’s another method if you can’t get mdfind to work.
set theFolder to choose folder -- and I choose the Library folder
set usrChc to "10052.html"
-- must remove trailing slash from the end of posix path of theFolder so that the result is proper
set posix_theFolder to POSIX path of theFolder
if last character of posix_theFolder is "/" then set posix_theFolder to text 1 thru -2 of posix_theFolder
set theFiles to paragraphs of (do shell script "find " & quoted form of posix_theFolder & " | grep " & quoted form of ("/" & usrChc))
Hi BLUEFROG and all
This is what I tried with mdfind.
It returns {}
Any ideas how to make it work?
I’d like to see if it is faster than grep
set theFolder to choose folder -- and I choose the Library folder
-- must remove trailing slash from the end of posix path of theFolder so that the result is proper
set posix_theFolder to POSIX path of theFolder
if last character of posix_theFolder is "/" then set posix_theFolder to text 1 thru -2 of posix_theFolder
set usrChc to "10052.html"
set theFiles to paragraphs of (do shell script "mdfind -onlyin " & quoted form of posix_theFolder & " \"kMDItemDisplayName == " & usrChc & "\"")
I modyfied this line so that it would not fail when Posix was the root of the HD and it returned “/” only
if posix_theFolder is not "/" and last character of posix_theFolder is "/" then set posix_theFolder to text 1 thru -2 of posix_theFolder
This works well but it brings up a lot of files inside all bundles, appls, themes etc.
set theseFiles to paragraphs of (do shell script "find " & quoted form of posix_theFolder & " | grep " & quoted form of ("/" & usrChc))
Is there a way to exclude them incorporating usrChch to something like:
The code below failed on the root level of my HD because of permission problem.
set theseFiles to paragraphs of (do shell script "find -x " & quoted form of POSIX path of theFolder & " -type d \\( -name '*.app' -o -name '*.pkg' -o -name '*.bundle' -o -name '*.help' -o -name '*.framework' -o -name '*.theme' -o -name '*.plugin' -o -name '*.wdgt' -o -name '*.abbu' \\) -prune -print0 -o -type f ! -name " & quoted form of (usrChc as text))
I made itwork.
However it finds files inside bundles etc.
I need to skip them.
I have been working, with the help of the MacScripter community, on this to prune them away from the search
This returns all uniq dups filenames.
set dups to paragraphs of (do shell script "find -x " & quoted form of POSIX path of theFolder & " -type d \\( -name '*.app' -o -name '*.pkg' -o -name '*.bundle' -o -name '*.help' -o -name '*.framework' -o -name '*.theme' -o -name '*.plugin' -o -name '*.wdgt' -o -name '*.abbu' \\) -prune -print0 -o -type f ! -name '.*' -print0 | xargs -0 basename -a | sort -d -f | uniq -d")
I would like to be able to eliminate the basename filter so that I would have the whole path of the files.
I also would like to change the uniq so that it lists only the duplicates but all of them.
Is this possible?