Add suffix and move to destination folder

This script when invoked acts on the currently selected files as follows.
Dialog pops up as per below.
2021-01-08 06h20m48Pro Dialog Box

A suffix option can be selected from the pulldown menu.
These can be edited in the script to suite.
My pulldown is shown below
2021-01-08 06h21m04Pro Pulldown menu

There are 2 flavours of action that can be taken:
-Text option (First one) - Upon selecting this option and clicking Ok a second dialog box with an empty text field pops up.
Populate the text field with the desired suffix and clock ok.
The selected files then are renamed by adding the entered string as a suffix to the file.
Script ends.
-All other options - These are pre-coded suffixes which can be edited.
Select one and click ok.
The currently selected files are renamed by adding the suffix to the files.
For some options script now ends.
For some other options as defined by a case statement the selected files are now copied to a predefined destination which is a function of the suffix.
In my example several suffixes are automatically moved to a destination folder defined by the alias /Kids.
Another group of suffixes are automatically moved to a destination folder defined by the alias /Daily.
Etc.
This can easily be tailored to your needs by editing the script.
I hope this is of some use to someone out there on the planet

' 2019-03-16 Take2.vbs
' 2021-01-01 Debug lxp help
'
Option Explicit
Function OnClick(ByRef clickData)
' ---------------------------------------------------------
DOpus.ClearOutput
Dim cmd, lister, tab, selItem, folderEnum, folderItem, dlg, ret, Suffix
' ---------------------------------------------------------

'=========================================================================================================
'
DOpus.ClearOutput
DOpus.Output "001000 01 Sample Pulldown No OnClick START"
' Create a Dialog object.
Set dlg = clickData.func.Dlg
' Initialise the object to display a drop-down control that lets the user pick one option from a list of many
'dlg.window = DOpus.Listers(0)
dlg.message = "Drop-down listdialog message"
dlg.title = "Drop-down Dialog Title"
dlg.max = 20
dlg.buttons = "OK|Cancel"
dlg.choices = DOpus.Create.Vector("- Text", "ATOTaxInv", "DailyT", "Dinner", "Gym", "Hint", "House", "Ingrid", "Kids", "Kirra", "Luke", "Maxalt 1.0", "Maxalt 0.5", "Netbank", "RJ", "RJ Netball", "SNOW", "TransUrban", "Tomb", "zxc")
dlg.selection = 0
' Show the dialog and print the results to the script log
ret = dlg.Show()
	DOpus.Output "001050 Dialog.Show returned :" & ret
	DOpus.Output "001060 The selected choice was :"  & dlg.choices(dlg.selection)

Set cmd = clickData.func.command
	cmd.deselect = false ' Prevent automatic deselection

if dlg.choices(dlg.selection) = "- Text" then
	DOpus.Output("0001200A Should be 0: " & dlg.choices(dlg.selection))
	DOpus.Output("0001201A Show text dialog")
	cmd.AddLine "rename PATTERN (.*)(\..*) TO ""\1 {dlgstring|SuffiXXX}\2"" REGEXP"
else
	DOpus.Output("0001200B dlg.choices(dlg.selection)) :" & dlg.choices(dlg.selection))
	Suffix = dlg.choices(dlg.selection)
	DOpus.Output("0001210B Suffix                      :" & Suffix)
' START This command breaks the subsequent copy move attempt
	cmd.AddLine "rename PATTERN (.*)(\..*) TO ""\1 " &Suffix & "\2"" REGEXP"
' END   This command breaks the subsequent copy move attempt
	cmd.AddLine "Clipboard SET " &Suffix
end if

'==== START Try copy to destination Folder ==================
if dlg.choices(dlg.selection) = "DailyT" then
	DOpus.Output("0001300A Should be DailyT: " & dlg.choices(dlg.selection))
	DOpus.Output "0001302A Dialog.Show returned :" & ret
	DOpus.Output("0001305A cmd.filecount   : " & cmd.filecount)
' START
	cmd.AddLine("copy move to /Daily")
' END
	DOpus.Output("0001310A copy move to /Daily complete")
end if
'==== END  Try copy to destination Folder ==================

DOpus.Output("0002000 dlg.choices(dlg.selection)   : " & dlg.choices(dlg.selection))
Select Case dlg.choices(dlg.selection)
   Case "ATOTaxInv", "Netbank"
		DOpus.Output("0002300 Should be gym: " & dlg.choices(dlg.selection))
		DOpus.Output "0002302 Dialog.Show returned :" & ret
		DOpus.Output("0002305 cmd.filecount   : " & cmd.filecount)
		' START
		cmd.AddLine("copy move to /Invoices")
		' END
		DOpus.Output("0002310 copy move to /Daily complete")
   Case "Ingrid", "RJ", "RJ Netball", "Luke", "Kirra"
		DOpus.Output("0002400                      : " & dlg.choices(dlg.selection))
		DOpus.Output "0002402 Dialog.Show returned :" & ret
		DOpus.Output("0002405 cmd.filecount   : " & cmd.filecount)
		' START
		cmd.AddLine("copy move to /Kids")
		' END
		DOpus.Output("0002410 copy move to /Kids complete")
   Case "Maxalt 1.0", "Maxalt 0.5", "Hint", "Dinner", "Gym"
		DOpus.Output("0002500                      : " & dlg.choices(dlg.selection))
		DOpus.Output "0002502 Dialog.Show returned :" & ret
		DOpus.Output("0002505 cmd.filecount   : " & cmd.filecount)
		' START
		cmd.AddLine("copy move to /Daily")
		' END
		DOpus.Output("0002510 copy move to /Daily complete")
   Case "zzzz"
      result_n
	Case Else
End Select

DOpus.Output("0090000 cmdRun()")
cmd.Run()
DOpus.Output "0090010 Done"
End Function
2 Likes

It might make sense to comment out all the DOpus.Output lines used for debugging so they don't add lots of noise to people's script logs.

2 Likes

And while you are at it: Add a button file or the xml code to make it easier for others to try out your work.

1 Like