Modifying Kind, File Type, File Identifier of doc files

Hi All,

Years go by between 2 similar scripts and I feel like OSs and other things change along.
Thought one could modify Kind, File Type, File Identifier of files through Info for. But doesn’t seem to work (any more).
So my question is: is it just me or it was possible in other times?

Main question remaining to be: is there any way of batch converting (1000s of files) those properties so that old doc files can open in recent Word application by simply double-clicking the file? Don’t know if this would work actually. I tried to textutil -convert to doc, which works in a way, but rubbish characters appear at the beginning of the file as well as at the end of it. (I guess it’s why Word refuses to open those files throwing an alert.)

Can I change kMDItemKind, &c. in some way?

Thanks ahead!

What if you give them the name extension “.doc” ?

Yvan KOENIG running Sierra 10.12.1 in French (VALLAURIS, France) jeudi 27 octobre 2016 20:34:25

Hi Yvan! Unfortunately that does not work. It seems to an inner file structure that would prevent the application from opening the files. The only extension is not sufficient. I’ve tried to modify by hand some of the things like the file ext to no avail.
Reading Kind, File Type, File Identifier show different results from openable and non-openable files so that I’d like to batch change those information. The file would then open in Word though some rubbish characters appearing at the beginning and at the end of the file, the main text remains to be readable and editable. At least would it open.

May you send me a sample file?

koenig yvan sfr fr

I would try to find a “not too bad” setting.

Yvan KOENIG running Sierra 10.12.1 in French (VALLAURIS, France) mercredi 2 novembre 2016 10:33:51

C’est parti ! :slight_smile:

Did you install an newer version of your application or helper application for example? It could be that an md import plug-in is overwriting your changes constantly.

Modifying the doc’s properties kind, type, identifier doesn’t help with .doc files. The OP should convert them to .docx format. He can achieve this using my script Converting old DOC to DOX - need help with file dates which is directly related to OP’s question.

Here it is:

set finderObjects to choose folder -- or you can [b]set finderObjects to choose file[/b]   
set all_Files_List to {}
set shell_Command to "/Applications/ --headless --convert-to docx --outdir "

--If item is file, then process as file... else process as folder
if folder of (info for finderObjects) is false then
	tell application "System Events" to set nameExt to name extension of finderObjects
	if nameExt ≠ "doc" then return -- If is file, but not ".doc", then quit application
	tell application "System Events" to set end of all_Files_List to (POSIX path of finderObjects)
	get_All_doc_Files_of_Folder(finderObjects, all_Files_List)
end if

--If no ".doc" files founded then exit application
if all_Files_List = {} then return

--Else converting ".doc" files with LibreOffice and save ".docx" files at same directory     
repeat with next_File in all_Files_List
	set outDir to do shell script "dirname " & "\"" & next_File & "\""
	do shell script shell_Command & "\"" & outDir & "\"" & space & "\"" & next_File & "\""
	set new_File to next_File & "x" --comment this or remove if you don't need
end repeat

--Brief  notification for converting results
display dialog "Processed Files: " & ((count of all_Files_List) as string) with title "Word DOC to DOCX processing complete"

on get_All_doc_Files_of_Folder(the_folder, all_Files_List)
	tell application "System Events"
		set files_list to every file of the_folder whose type identifier is ""
		repeat with doc_Item in files_list
			set end of all_Files_List to POSIX path of doc_Item
		end repeat
		set sub_folders_list to folders of the_folder
	end tell
	--A recursive subroutine call itself to search for ".doc" files  in subfolders too
	repeat with the_sub_folder_ref in sub_folders_list
		my get_All_Files_of_Folder(the_sub_folder_ref, all_Files_List)
	end repeat
end get_All_doc_Files_of_Folder

NOTE: using AsObjC someone can make my script even faster. AsObjC variant (to get entire contents of chosen folder) of my script (from someone who is not too lazy) will only greet.