• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problems with Mac to PC names conversion script. setuid command on a Mac server
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with Mac to PC names conversion script. setuid command on a Mac server


  • Subject: Re: Problems with Mac to PC names conversion script. setuid command on a Mac server
  • From: Levon Spradlin <email@hidden>
  • Date: Wed, 17 Oct 2007 11:41:37 -0500
  • Thread-topic: Problems with Mac to PC names conversion script. setuid command on a Mac server

Title: Re: Problems with Mac to PC names conversion script. setuid command on a Mac server
Brett,
    Have you tried to fix the permissions issue on the server? We had to run a setuid command on our XServe to help fix permissions of files transferred back and forth from the server to workstations. The files kept retaining workstation permissions on the server. I am not sure of the details, but you can read up a bit about it yourself. http://en.wikipedia.org/wiki/Setuid
    If your server admin is experienced, this should be a quick fix that works fine after a reboot. Good luck!

Levon Spradlin
Technology Manager, Desktop Publishing Support Services
Pearson | Assessment & Information
512-989-5300 x 3989
email@hidden








From: Brett Conlon <email@hidden>
Date: Wed, 17 Oct 2007 09:04:04 +1100
To: <email@hidden>
Subject: Problems with Mac to PC names conversion script


Hi all,

Can anyone suggest a way to improve/fix an issue with the below script where it chokes on files on a Mac Server which are either locked or have incorrect permissions. I'm part way there with detecting the error type with bad permissions but I've had problems actually getting the script to successfully change the permissions on the Mac Server - even if it is a read/write volume.

Here's the script:

#############################################################

(* requires Satimage.osax *)

property myListOfChar : {"/", "\\", "?", "|", "*", "<", ">", "\""} --last entry is for a single quote "
property myReplacementChar : {"-", "-", "X", "_", "_", "_", "_", "'"} --last entry quote replaced by an apostrophe

to open itemlist
       process_items from itemlist
end open

to run
       process_items from navchoose object with prompt ¬
              "Choose folders or files to check/rename:" with multiple files
end run

to process_items from itemlist
       set mainFileList to {}
       set mainFolderList to {}
       set renamedFiles to {}
       set renamedFolders to {}
       tell application "Finder" to repeat with currItem in itemlist
              set currClass to item currItem's class
              if currClass is document file then
                      set mainFileList's end to currItem's contents
              else if currClass is folder then
                      set mainFolderList's end to currItem's contents
              end if
       end repeat
       check_items from mainFileList against renamedFiles
       process_folders from mainFolderList against {renamedFiles, renamedFolders}
       display dialog (results_summary for {renamedFiles, renamedFolders}) buttons "OK" default button 1
end process_items

to check_items from itemlist against renamedList
       tell application "Finder" to repeat with currItem in itemlist
              set currName to currItem's name as Unicode text
              set newname to (change myListOfChar into myReplacementChar in currName) as Unicode text
              if newname is not currName then
                      set renamedList's end to currName
                      try
                             set currItem's name to newname
                      on error number the error_number
                             if the error_number is -48 then --("The operation could not be completed because there is already an item with that name.") the error_message number the error_number
                                     if name extension of currItem is not "" then
                                            set CurrItemExt to name extension of currItem
                                            set ExtNumChars to number of characters of CurrItemExt --determine if 3 or 4 char extension.
                                            set newname to (text 1 thru -(ExtNumChars + 2) of newname) & "-1." & CurrItemExt
                                     else
                                            set newname to (newname & "-2.")
                                     end if
                                     set currItem's name to (newname)
                             else if the error_number is -45 then -- "The operation could not be completed because the file “XXX” is locked."
                                     select currItem
                                     tell me to display dialog "The file selected in the Finder is locked and the script is unable to fix the incorrect characters in its name. Please resolve this file manually when the script is finished (ask the Technical Coordinator for assistance if required)." buttons {"Cancel", "OK"} default button 2
                             else if the error_number is -5000 then -- "The operation could not be completed because you do not have enough access privileges."
                                     select currItem
                                     tell me to display dialog "Due to insufficient privileges the script is unable to fix incorrect characters in the name of the file which is selected in the Finder. Please ask the Technical Coordinator to assist you to resolve this after the script has finished processing.)." buttons {"Cancel", "OK"} default button 2
                             end if
                      end try
              end if
       end repeat
end check_items

to process_folders from mainFolderList against {renamedFiles, renamedFolders}
       tell application "Finder" to repeat with mainFolder in mainFolderList
              set allItems to (a reference to mainFolder's entire contents)
              if (count document files of allItems) > 0 then ¬
                      my (check_items from (get document files of allItems) against renamedFiles)
              set folderCount to count folders of allItems
              if folderCount is 0 then
                      set folderList to {}
              else if folderCount is 1 then
                      set folderList to folders of allItems as alias as list
              else
                      set folderList to folders of allItems as alias list
              end if
              set folderList's end to mainFolder's contents (* optional: include top-level folder *)
              my (check_items from folderList against renamedFolders)
       end repeat
end process_folders

on results_summary for {renamedFiles, renamedFolders}
       set reportFiles to (count renamedFiles) > 0
       set reportFolders to (count renamedFolders) > 0
       if not (reportFiles or reportFolders) then return "No name changes were necessary."
       set msg to "The following names were changed:"
       set tid to text item delimiters
       set text item delimiters to return & tab
       if reportFiles then set msg to msg & return & return & {"Files:", "", ""} & renamedFiles
       if reportFolders then set msg to msg & return & return & {"Folders:", "", ""} & renamedFolders
       set text item delimiters to tid
       msg
end results_summary

#############################################################

I have used the code from the following applet in the past to try and fix the permissions but as I mentioned it would fail at making the changes:

#############################################################

on open (Folderz)
       try
              repeat with thisFolder in Folderz
                      set filePath to quoted form of POSIX path of thisFolder
                      do shell script "chmod -R 777 " & filePath
              end repeat
              display dialog "Permissions changed successfully." buttons {"Thanks!"} default button 1
       on error
              display dialog "Changing permissions failed. Please try it manually" buttons {"OK"} default button 1
       end try
end open

on run
       try
              set aFolder to choose folder with prompt "Please choose a folder to process"
              set filePath to quoted form of POSIX path of aFolder
              do shell script "chmod -R 777 " & filePath
              display dialog "Permissions changed successfully." buttons {"Thanks!"} default button 1
       on error
              display dialog "Changing permissions failed. Please try it manually" buttons {"OK"} default button 1
       end try
end run

#############################################################

Your help is most appreciated!

Cheers,

Brett

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

****************************************************************************

This email may contain confidential
material. If you were not an intended recipient,
Please notify the sender and delete all copies.
We may monitor email to and from our network.

 ***************************************************************************

 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Problems with Mac to PC names conversion script (From: Brett Conlon <email@hidden>)

  • Prev by Date: Re: AppleScript 2.0?
  • Next by Date: Grab the document's path of a Numbers's window
  • Previous by thread: Problems with Mac to PC names conversion script
  • Next by thread: Re: Problems with Mac to PC names conversion script
  • Index(es):
    • Date
    • Thread