|
|
#1 |
|
Prospect
Join Date: Feb 2006
Posts: 14
|
File finder script for networked computers
Ive tried to do this script and failed. Hopefully someone can help me.
I need to: 1. do a search across 6 networked computers to find a file.(Needs to ask for a file name) 2. If the computers arent mounted the need to be mounted 3. Once that file is found i need a window showing what the computer name and folder it is located on, and all the info of the file itself. any ideas? I am using osx10.6.8 |
|
|
|
|
|
#2 |
|
Hall of Famer
Join Date: Apr 2007
Posts: 4,262
|
are the computers normally mounted on the searching computer? If so, this is easy to do in applescript; if not, you'll either have to mount them or ssh into each to do the search.
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW- |
|
|
|
|
|
#3 |
|
Prospect
Join Date: Feb 2006
Posts: 14
|
They are already mounted on the searching computer. Im new at this so i really struggled getting it to work
thanks |
|
|
|
|
|
#4 |
|
Hall of Famer
Join Date: Apr 2007
Posts: 4,262
|
well, start with this, which does the search (assuming that everything is mounted at /volumes, as is typical)
Code:
tell application "Finder" set volumeList to name of every disk end tell display dialog "What file are you looking for?" default answer "" set fileToFind to text returned of the result repeat with thisVolume in volumeList set cmd to "mdfind \"kMDItemFSName = " & fileToFind & "\" -onlyin '/volumes/" & thisVolume & "'" set foundFiles to (do shell script cmd) if foundFiles ≠ "" then display alert "Files Found" message foundFiles exit repeat end if end repeat
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW- |
|
|
|
|
|
#5 |
|
Prospect
Join Date: Feb 2006
Posts: 14
|
thank you for that, it works great. The disk are the network shares from the other computers, to mount a disk i have to use the example string: afp://Copper._afpovertcp._tcp.local. This mounts all the shared folders on that computer.
|
|
|
|
|
|
#6 |
|
Hall of Famer
Join Date: Apr 2007
Posts: 4,262
|
well, mounting an afp share should be straight-forward:
Code:
mount volume "afp://Copper._afpovertcp._tcp.local" Code:
tell application "Finder" set thisDiskIsMounted to exists disk disk_name end tell if not thisDiskIsMounted then mount volume disk_name on server "afp://Copper._afpovertcp._tcp.local" end if
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW- |
|
|
|
|
|
#7 |
|
Prospect
Join Date: Feb 2006
Posts: 14
|
Thank you again for your help. ive set it up like this:
try mount volume "afp://Copper._afpovertcp._tcp.local" mount volume "afp://Zinc._afpovertcp._tcp.local" mount volume "afp://Titanium._afpovertcp._tcp.local" mount volume "afp://Lead._afpovertcp._tcp.local" mount volume "afp://Thorium._afpovertcp._tcp.local" mount volume "afp://Lithium._afpovertcp._tcp.local" end try set searchTerm to text returned of (display dialog "Enter search term" default answer "") set theSearch to do shell script "find -f /Volumes/ | grep " & quoted form of searchTerm if theSearch ≠ "" then display alert "Files Found" message theSearch end if if theSearch = "" then display alert "Files Not Found" message theSearch end if The search works, however when it comes to a drive that is local(mine is lead) it comes up with this message: Connection Failed The server "Lead" is available on your computer. Access the volumes and files locally. When i click ok it brings up the enter search term window without mounting the drives located after my drive. Is there a way to have this script ignore the local drives? I need to be able to use this script on all the computers in the group so i cant write it just for mine, otherwise i would just delete mounting my drive. Thank you |
|
|
|
![]() |
| Tags |
| applescript, file search, networked |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|