OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Utilities => Topic started by: Martin Iturbide on October 10, 2023, 10:51:37 pm

Title: How to change several files "Class Type" in one shot
Post by: Martin Iturbide on October 10, 2023, 10:51:37 pm
Hello

Long time ago, someone taught me on this forum to use FT to change the "WPS File type" in several files at once.
I wrote this to don't forget about it: "Changing the WPS File type on Several Files at Once (https://www.os2world.com/wiki/index.php/Changing_the_WPS_File_type_on_Several_Files_at_Once)"

But now I want to change the "Class Type" of several files at once. (Check the image attached to understand me better). I want to change several .lgo image files from "WPDataFile" to "MMImage" without going one by one. Is there a way?

Regards
Title: Re: How to change several files "Class Type" in one shot
Post by: Lars on October 11, 2023, 07:28:02 pm
I only see two ways, a "clean" way and a "dirty" way:

1) "dirty" way: rewrite the ".CLASSINFO" EA: the structure itself is undocumented but the CWMM classes source code contains a description of that EA.

2) "clean" way: write a WPS class that provides a user interface and that uses the undocumented "ClassAssociationManager" class to set the object class. That is exactly the class the existing user interface uses. But that would need some reengineering to find out the call parameters and return values of the methods that class contains.

There currently is no user interface to do that for multiple files.
Title: Re: How to change several files "Class Type" in one shot
Post by: Lars on October 12, 2023, 01:10:12 am
I just realized that in the past I had already started with the "clean" way and already reverse engineered the call parameters and return values of the "ClassAssociationManager" methods.

Maybe I will be able to come up with something.
Title: Re: How to change several files "Class Type" in one shot
Post by: Martin Iturbide on October 12, 2023, 03:01:57 am
Thanks Lars for the feedback.

It would be awesome if you can produce something and I appreciate that.
I may be looking like a simple command line tool (like FT) where I can run something like: ClassCh *.lgo "MMIMAGE"
... or whatever comes to your mind  ;D

Regards
Title: Re: How to change several files "Class Type" in one shot
Post by: Lars on October 12, 2023, 08:18:16 am
Thanks Lars for the feedback.

It would be awesome if you can produce something and I appreciate that.
I may be looking like a simple command line tool (like FT) where I can run something like: ClassCh *.lgo "MMIMAGE"
... or whatever comes to your mind  ;D

Regards

I would love to create a command line tool but I cannot. That's because I need object pointers of the file objects whose object class (type) you want to change.
And I will only get them on drag and drop when these objects are dragged and dropped onto a window. Therefore the minimum would be to create a dialog box with a container to allow drops of multiple files.

A command line tool would only allow the "dirty" hack and I am reluctant to implement that because I don't know the side effects.
I'll have to think about that a little more ...
Title: Re: How to change several files "Class Type" in one shot
Post by: Rich Walsh on October 13, 2023, 05:30:26 am
Attached is 'oo' v1.15 which now offers a "Become" command.

If you are running AOS, you already have 'oo' v1.10 in x:\sys\bin. Backup that copy (just in case), then replace it with this version. If not, download RWS v0.80 from hobbes, install it, then replace its copy of 'oo' with this one.

The syntax for the new command is:  oo  /B  <file>  <className | file2>

Supply the name of the file or folder to be changed, then specify either the name of the new class _or_ the name of a file or folder that is already the class you want. If successful, 'oo' will change the class, update the '.TYPE' EA as needed, and reset the object to the class' default view.

Run 'oo' with no arguments to get its help screen. Refer to 'oo.txt' for more details (on AOS, it's in 'x:\sys\doc\oo').
Title: Re: How to change several files "Class Type" in one shot
Post by: Martin Iturbide on October 13, 2023, 07:10:23 pm
Thanks Rich

It works, but only for single files, it does not support wildcards.

Ex:  oo /B aa.bmp WPDataFile
Worked fine

Ex:  oo /B *.bmp WPDataFile
says "'*' and '?' are not supported"

Regards
Title: Re: How to change several files "Class Type" in one shot
Post by: Rich Walsh on October 13, 2023, 09:48:11 pm
It works, but only for single files, it does not support wildcards.

BMP2DATA.CMD
------------------
oo /+
for %%1 in (*.bmp) do oo /B %%1 WPDataFile
oo /-
------------------
Title: Re: How to change several files "Class Type" in one shot
Post by: Martin Iturbide on October 13, 2023, 11:25:45 pm
Thanks Rich !!!
Title: Re: How to change several files "Class Type" in one shot
Post by: Martin Iturbide on October 15, 2023, 01:24:05 am
Thanks Lars

The application also worked fine for me and it is also a keeper for me.
Here it is quick video I made: https://youtu.be/xSMfSpgJp7I

Rich, Lars, will it be ok to package (add some readme info, etc) your releases and upload them to hobbes?

Regards
Title: Re: How to change several files "Class Type" in one shot
Post by: Rich Walsh on October 15, 2023, 05:49:38 am
Rich, [...] will it be ok to package (add some readme info, etc) your releases and upload them to hobbes?

Thanks for the offer, but "No, please don't". The same goes for 'csm2uefi' and other things I may post here.

Most of this stuff was created either in response to a particular user's needs (in this case, yours) or to some short-term need (e.g. csm2uefi), and isn't ready and/or suitable for widespread distribution. When it is (if ever), I will handle the details.
Title: Re: How to change several files "Class Type" in one shot
Post by: Lars on October 15, 2023, 09:38:30 am
Same goes for me, but for other reasons. After using it myself a couple of times, it turns out that my solution has triggered another problem I was not expecting: dropping objects onto my Assoc Object and having their object class changed will trigger removal and readd of that dropped object in its containing folder (the one it has been dragged from) which also forces it onto the "next free space" in that container.

And if you drop more than one object at once, that will then screw up the WPS because it seemingly gets confused what the "next free space" is which results in a longer block of the WPS. I do not know how to deal with this and I therefore withdrew my posting.

In the end, a batch solution like Rich has now created is the better choice anyways. But maybe Rich can be convinced to auto-select the object target class so that the user does not have to be bothered :-)
Title: Re: How to change several files "Class Type" in one shot
Post by: Lars on October 20, 2023, 04:08:11 pm
Now uploaded to Hobbes, including source code (for those interested).
You should drop everything else and use what I have uploaded.
Title: Re: How to change several files "Class Type" in one shot
Post by: Martin Iturbide on October 21, 2023, 04:22:48 am
Thanks Lars for uploading it and sharing the source code.

Regards
Title: Re: How to change several files "Class Type" in one shot
Post by: Martin Iturbide on October 21, 2023, 10:40:59 pm
Hi

Sorry if this is crazy talk, or enters more in the real of personal opinion.  Which class do you think is better for a DLL file?

Here I attach a pic of two DLLs one is WPPngDataFile and the other WPPngProgramFile.

I kind of like that DLLs are "WPPngProgramFile" more for DLLs, since it shows the "Module", "Resources" and "Language" tabs with more executable information.

Regards

Title: Re: How to change several files "Class Type" in one shot
Post by: Lars on October 22, 2023, 03:19:16 pm
I think you have given yourself the answer:

only if the object class is WPPngProgramFile (or XWPProgramFile if you do not have PNG desktop installed) will you see the module and resource info pages (for DLLS and EXEs) and the Program and Session pages (for EXEs).

Since I am a programmer, I find the Module and Resource pages for DLLs helpful but you can decide for yourself. My "AssocCls" tool would make a DLL file a XWPProgamFile/WPPngProgramFile object because that is the most specialized object class for a DLL file.
Title: Re: How to change several files "Class Type" in one shot
Post by: Martin Iturbide on October 22, 2023, 03:52:23 pm
Hi Lars

..My "AssocCls" tool would make a DLL file a XWPProgamFile/WPPngProgramFile object because that is the most specialized object class for a DLL file.

I have just a little issue here. With "AssocCls" (the latest version on hobbes), if I drag a DLL file into it, it does not change it to "XWPProgramFile/WPPngProgramFile", it remains as WPPngDataFile. The only thing special on my ArcaOS 5.1 VM is that I like to install the full XWorkplace program.

Regards
Title: Re: How to change several files "Class Type" in one shot
Post by: Lars on October 27, 2023, 01:21:25 am
Looks like if a DLL is in use, it cannot be changed this way. Too bad.
Maybe you can try and run "unlock.exe" against the DLL you want to change before you attempt to drop it onto the AssocCls Object.
Title: Re: How to change several files "Class Type" in one shot
Post by: Lars on October 29, 2023, 12:45:13 pm
Per coincidence I found the following: if you use EAUTIL.EXE to strip a file of all of its EAs, then, the object will automatically revert back to the most specialized class there exists when the object is again displayed in a folder.

To strip EAs of all .ICO files, do something like this: for %F in (*.ico) do @eautil.exe %F NUL /S

There is a drawback to this: because ALL EAs of a file are stripped in this way, so is the .LONGNAME EA which is the EA holding an objects long name/title.

So, the easiest thing would be to write a tool that strips a file of all its EAs except for the .LONGNAME EA (or equivalently, one that saves the .LONGNAME EA, strips off all EAs and restores the .LONGNAME EA).