About

This script creates directories corresponding to selected .info files. It is useful perhaps for drawer collections where you already have an ".info" file, which you know corresponds to a directory icon type and you must create the directory itself.

Download

How to Install

  1. Extract the archive
  2. Place DOpus4-AddDir.rexx wherever you see fit (it is tidy, for example, to create an ARexx directory in DOPUS4: and then place your scripts there).
  3. Open DirectoryOpus4 and right-click and go to Project→Configure
  4. On the screen that pops-up, go to Buttons and create a new button somewhere where you see fit.
    1. Give the button a name (AddDir, for example) and create a new entry.
    2. Set the cycler to ARexx and click the magnifying glass to enter the path to the DOpus4-AddDir.rexx script.
  5. You do not need to set any flags.
  6. Save and exit and you are done.

How To Use

After adding the button, locate an ".info" file which you know that it is an ".info" file for a directory and press the button that you created. This will create the directory named after the name of the ".info" file with the ".info" substring removed from the directory name.

Developer Notes

The script uses a custom-implementation of some functions which can all be found on the ARexx FUSS page.

Code

DOpus4-AddDir.rexx
/*
 *  $VER: DOpus4-AddDir 1.0 (06 Jul 2015) by Wizardry and Steamworks
 *
 *      © 2015 Wizardry and Steamworks
 *
 *  PROGRAMNAME:
 *      DOpus4-AddDir
 *
 *  FUNCTION:
 *      Adds a directory for selected .info files.
 *
 *  USAGE:
 *      ARexx command DOpus4-AddDir.rexx (from DOpus)
 *
 *  $HISTORY:
 *
 *  06 Jul 2015 : 1.0 : initial release
 */
 
Opus = Address()    /* Get the DOpus address. */
Options RESULTS     /* Request results. */
Address value Opus  /* Use the DOpus address. */
 
Busy On
 
Status 3                    /* Get this window. */
ThisWindow = RESULT
 
/* Get this window's selected items. */
TopText "Getting this window's items..."
GetSelectedAll '*' ThisWindow               /* Split entries by delimiter since we may have spaces. */
ThisItems = RESULT
If ThisItems = 'RESULT' Then                /* If no items in this window then bail. */
    Do
        TopText "No items selected in this window!"
        Busy Off
        Exit
    End
 
/* Normalize, heh... */
ThisItems = Translate(Translate(ThisItems, '/', ' '), ' ', '*')
 
/* Add a directory for all selected .info files. */
TopText "Adding directories..."
GetAll '*' ThisWindow
AllItems = RESULT
 
/* Normalize, heh... */
AllItems = Translate(Translate(AllItems, '/', ' '), ' ', '*')
 
Count = Words(AllItems)
Do i = 1 To Count
    ThisName = SubWord(AllItems, i, 1)
 
    /* If the file is not selected, then skip it. */
    If Find(ThisItems, ThisName) = 0 Then Iterate i
    /* If the file is not an info file, then skip it. */
    If Pos('.info', ThisName) = 0 Then Iterate i 
 
    /* Create the new name without '.info'. */
    InfoName = SubStr(ThisName, 1, Length(ThisName)-5)
 
    /* If the new name is empty, then skip it. */
    If Length(InfoName) = 0 Then Iterate i
    /* If the new name already exists, then skip it. */
    If Find(ThisItems, InfoName) ~= 0 Then Iterate i
 
    /* Restore original spaces. */
    InfoName = Translate(InfoName, ' ', '/')
 
    /* Get the path to the entry. */
    Status 13 i + 1
    Path = RESULT
 
    /* Compose the directory name. */
    DirsName = Path||InfoName
 
    /* Scroll to the '.info' item. */
    ScrollToShow Translate(ThisName, ' ', '/')
 
    /* Make the directory. */
    Address COMMAND 'makedir >NIL: "'DirsName'"'
 
    /* If the directory could not be created, then skip deselect. */
    If RC ~= 0 Then Iterate i
 
    /* Deselect entry. */
    SelectEntry i - 1 ||' '|| 0 ||' '|| 1   
End
 
/* Final rescan to update the window pane. */
ReScan ThisWindow
 
TopText "(>-.-)/ There you go!"
Busy Off
Exit

amiga/directoryopus/4/adddir.txt · Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.