/* * $VER: DOpus4-AddInfoDummy 1.0 (06 Jul 2015) by Wizardry and Steamworks * * © 2015 Wizardry and Steamworks * * PROGRAMNAME: * DOpus4-AddInfoDummy * * FUNCTION: * Adds a dummy file for selected .info files. * * USAGE: * ARexx command DOpus4-AddInfoDummy.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 dummy files for all selected .info files. */ TopText "Adding dummy files..." 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. */ DumsName = Path||InfoName /* Scroll to the '.info' item. */ ScrollToShow Translate(ThisName, ' ', '/') /* Make the directory. */ Address COMMAND 'echo "" > "'DumsName'"' /* If the dummy 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