#move@script VBScriptOption ExplicitFunction OnClick(ByRef ClickData) Dim Testing, DeleteFiles, desPath, mapFolders, keyLength 'user configuration variables - must be set below before use Dim DoF Set DoF = DOpus.Create ' Create a DOpus.Factory object - Do Not Change this'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ' Change to 'False' to actually Copy/Delete real files!! Testing = True ' Change this to 'True' to delete the source files after they have been copied. A confirmation dialog will pop up DeleteFiles = False ' The desPath location must already exist. desPath = "D:\Test\" ' Testing location - change this suit your needs keyLength = 3 ' Set this to the number of characters in your map 'key' above ' Predefined destination folders based on file name - the 'key' should match srcStem (the first 3 chars of the selected file name) ' The folder/sub-folder must already exist at the destination. Don't forget the trailing "\" at the end. Set mapFolders = DoF.Map()' There should be no need to alter anything beyond here (unless I've made an error or there are improvements to be made) '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Dim selFiles, selFile, selStem, file ' Selected files Dim desFile, desFolder, desFilePath, defFolder ' Destination & Defined folder and/or files Dim userVer, fileVer, nameVer ' Version numbers & Map object Dim RegX, Matches, Match, StartPos, dlg, cmd, Return ' RegExp & Misc Dim DeleteConfirm Set dlg = ClickData.Func.Dlg Set cmd = ClickData.Func.command Set selFiles = ClickData.Func.sourcetab.selected_files ' Check that only files are selected. If ClickData.Func.sourcetab.selected_dirs.count > 0 Then dlg.request "Only Files should be selected", "OK" Exit Function End If ' Make sure we have at least one file selected If selFiles.count = 0 Then dlg.Request "Please select some files to move", "OK" Exit Function End If cmd.ClearFiles If Testing = False Then If DeleteFiles = True Then DeleteConfirm = dlg.request("Source Files will be deleted - Confirm", "OK|NO!") Else dlg.request "Source Files will not be deleted", "OK" End If End If ' Process each selected file (File) For Each file In selFiles ' Let's find out if the version number is in the file name and if not ' figure it out (or enter it manually) and insert it into the file name nameVer = "" ' initialise var Set RegX = New RegExp RegX.IgnoreCase = True RegX.Global = False RegX.Pattern = "([0-9]+\.)+" Set Matches = RegX.Execute(selFiles(file).name) For Each Match In Matches nameVer = Left(Match.Value,Len(Match.value)-1) If Len(nameVer) =< 3 Then ' ignore things like the '64' in DOpusInstall64.exe nameVer = "" End If Next Set fileVer = selFiles(file).metadata.exe StartPos = InStr(fileVer.prodversion,NameVer) If nameVer <> "" Then desFile = selFiles(file).name Else If NameVer <> "" And StartPos = 0 Then desFile = selFiles(file).name Else If fileVer.prodversion <> "" Then desFile = selFiles(file).name_stem & "_" & fileVer.prodversion & selFiles(file).ext Else userVer = dlg.GetString("Enter Version # for " & selFiles(file).name,,10,"OK|Cancel","Version Number Required") If userVer = "" Then desFile = selFiles(file).name Else desFile = selFiles(file).name_stem & "_" & userVer & selFiles(file).ext End If End If End If End If selStem = Left(desFile,keyLength) ' Get first letters of selected file name If mapFolders.exists(selStem) Then defFolder = mapFolders(selStem) desFolder = desPath & defFolder Else Set Return = dlg.folder("Select folder for " & desFile,desPath,1) If Return.result = False Then desFolder = desPath Else desFolder = Return & "\" End If End If desFilePath = Chr(34) & desFolder & desFile & Chr(34) selFile = ClickData.Func.sourcetab.path & "\" & selFiles(file).name ' I'm using two commands here (a 'Copy' followed by a 'Delete') because if a file already exists with a ' "Copy Move WHENEXISTS=SKIP", the existing file gets skipped and will remain in the source lister If Testing = True Then DOpus.Output(desFilePath) Else cmd.AddFile selFile If DeleteConfirm <> 0 Then cmd.RunCommand "Copy WHENEXISTS=SKIP AS " & Chr(34) & desFile & Chr(34) & " To=" & Chr(34) & desFolder & Chr(34) cmd.RunCommand "Delete QUIET" Else cmd.RunCommand "Copy WHENEXISTS=SKIP AS " & Chr(34) & desFile & Chr(34) & " To=" & Chr(34) & desFolder & Chr(34) End If cmd.ClearFiles End If NextEnd Function