Second version of the Office 2008 converter script
Well Steve Maser asked me to come up with a version that would work recursively on all files inside a folder you would drag to the script.
He also suggested that I added the W6BN type (for Word 6/95 files).
So I based the script on one of the examples provided by Apple, and here is the result:
-- This droplet processes files dropped onto the applet
on open these_items
repeat with i from 1 to the count of these_items
set this_item to item i of these_items
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else
tell application "Finder"
-- get the file type
set TheFileType to file type of this_item
set UpdatedFileType to TheFileType
-- detect old file types for Office files chose the correct one instead
if TheFileType = "WDBN" then set UpdatedFileType to "W8BN"
if TheFileType = "W6BN" then set UpdatedFileType to "W8BN"
if TheFileType = "XLS4" then set UpdatedFileType to "XLS8"
-- if TheFileType = "SLD8" then set UpdatedFileType to "SLD8"
-- set the new file type
set file type of this_item to UpdatedFileType
end tell
end if
end repeat
end open
-- Just in case people try to open the script through a double-click in the Finder.
on run
display dialog "Drop your files or folders to be converted on this icon"
end run
-- this sub-routine processes folders
on process_folder(this_folder)
set these_items to list folder this_folder without invisibles
repeat with i from 1 to the count of these_items
set this_item to alias ((this_folder as Unicode text) & (item i of these_items))
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else
tell application "Finder"
-- get the file type
set TheFileType to file type of this_item
set UpdatedFileType to TheFileType
-- detect old file types for Office files chose the correct one instead
if TheFileType = "WDBN" then set UpdatedFileType to "W8BN"
if TheFileType = "W6BN" then set UpdatedFileType to "W8BN"
if TheFileType = "XLS4" then set UpdatedFileType to "XLS8"
-- if TheFileType = "SLD8" then set UpdatedFileType to "SLD8"
-- set the new file type
set file type of this_item to UpdatedFileType
end tell
end if
end repeat
end process_folder
The compiled script is here and again, please make tests only on a copy of your files.
Feedbacks are much welcome.