Author Topic: How to change several files "Class Type" in one shot  (Read 17262 times)

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4937
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
How to change several files "Class Type" in one shot
« 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"

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
« Last Edit: October 11, 2023, 02:11:26 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Lars

  • Hero Member
  • *****
  • Posts: 1345
  • Karma: +68/-0
    • View Profile
Re: How to change several files "Class Type" in one shot
« Reply #1 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.
« Last Edit: October 11, 2023, 07:37:35 pm by Lars »

Lars

  • Hero Member
  • *****
  • Posts: 1345
  • Karma: +68/-0
    • View Profile
Re: How to change several files "Class Type" in one shot
« Reply #2 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.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4937
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: How to change several files "Class Type" in one shot
« Reply #3 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
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Lars

  • Hero Member
  • *****
  • Posts: 1345
  • Karma: +68/-0
    • View Profile
Re: How to change several files "Class Type" in one shot
« Reply #4 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 ...
« Last Edit: October 12, 2023, 08:20:45 am by Lars »

Rich Walsh

  • Sr. Member
  • ****
  • Posts: 349
  • Karma: +23/-0
  • ONU! (OS/2 is NOT Unix!)
    • View Profile
Re: How to change several files "Class Type" in one shot
« Reply #5 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').

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4937
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: How to change several files "Class Type" in one shot
« Reply #6 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
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Rich Walsh

  • Sr. Member
  • ****
  • Posts: 349
  • Karma: +23/-0
  • ONU! (OS/2 is NOT Unix!)
    • View Profile
Re: How to change several files "Class Type" in one shot
« Reply #7 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 /-
------------------

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4937
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: How to change several files "Class Type" in one shot
« Reply #8 on: October 13, 2023, 11:25:45 pm »
Thanks Rich !!!
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4937
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: How to change several files "Class Type" in one shot
« Reply #9 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
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Rich Walsh

  • Sr. Member
  • ****
  • Posts: 349
  • Karma: +23/-0
  • ONU! (OS/2 is NOT Unix!)
    • View Profile
Re: How to change several files "Class Type" in one shot
« Reply #10 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.

Lars

  • Hero Member
  • *****
  • Posts: 1345
  • Karma: +68/-0
    • View Profile
Re: How to change several files "Class Type" in one shot
« Reply #11 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 :-)
« Last Edit: October 15, 2023, 09:43:27 am by Lars »

Lars

  • Hero Member
  • *****
  • Posts: 1345
  • Karma: +68/-0
    • View Profile
Re: How to change several files "Class Type" in one shot
« Reply #12 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.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4937
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: How to change several files "Class Type" in one shot
« Reply #13 on: October 21, 2023, 04:22:48 am »
Thanks Lars for uploading it and sharing the source code.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4937
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: How to change several files "Class Type" in one shot
« Reply #14 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

Martin Iturbide
OS2World NewsMaster
... just share the dream.