Access File Topics programatically to better organise my files

  • 1
  • Question
  • Updated 1 year ago
Hi folks,

I had an idea about using the File type topics to make a reorg of some files on my computer, but I'm at a loss in trying to find where 'Name', 'Date Created', 'Date Modified' & 'URL' etc are stored

The referenced map explains it in more detail. I have the code to iterate through the topics in a branch. https://drive.google.com/file/d/0BwidG_nnMr5KcFdZSHVtaUJPMHM/view?usp=sharing


Any help is appreciated - I'll publish the finished macro here later

Many thanks
/Eamonn
Photo of Eamonn Edwardo

Eamonn Edwardo

  • 11 Posts
  • 2 Reply Likes

Posted 1 year ago

  • 1
Photo of Eamonn Edwardo

Eamonn Edwardo

  • 11 Posts
  • 2 Reply Likes
So, I made some progress.

I now have a macro that creates the desired folder structure -- rather it outputs the MKDIR statements for the structure to the debug window, where I saves them as a Powershell file --
one can highlight the desired folder and run the macro.



I found the file name stored in Selection.PrimaryTopic.Hyperlink.Adddress -- this is the entire original location, I have not found 'Date Created' or 'Date Modified' but don't require in this version.

To build the XCOPY statement that will move the files / folders to their reorganised location, I need the portion of the filname after the last '\'  -- hence all the trickery below with the hyperlink length.

XCOPY "E:\TEMP\JB-NOTES_2017-08-30" "E:\MYDOCSTEST\BUSINESS\PROJECTS\SECRET-PROJECT\JB-NOTES_2017-08-30" /S /I
/S - includes subfolders
/I - /I If destination does not exist and copying more than one file,  assumes that destination must be a directory.

Sub Main
Dim s_FileHyperlink As String Dim i_PositionOfFinalSlash As Integer ' where the final backslash '\' occurs Dim i_LengthFileHyperlink As Integer ' total length of Hyperlink Dim s_FileRHS As String ' RHS of file - this will get appended to XCOPY destination path On Error GoTo ErrorHandler ' Use WWB string funtions to find final "\" With ActiveDocument.Selection.PrimaryTopic s_FileHyperlink = .Hyperlink.Address i_PositionOfFinalSlash = InStrRev(s_FileHyperlink, "\") ' start looking from the reverse - but number is from beginning i_LengthFileHyperlink = Len(s_FileHyperlink) - i_PositionOfFinalSlash ' subtract from total length s_FileRHS = Right(s_FileHyperlink, i_LengthFileHyperlink) MsgBox("Notes: " & CStr(.Notes.Text) & vbCrLf & _ "Full Hyperlink: " & CStr(.Hyperlink.Address) & vbCrLf & _ "Found '\' at position: " & i_PositionOfFinalSlash & vbCrLf & _ "RHS of file: " & s_FileRHS) End With End ErrorHandler: MsgBox(Err.Description, vbExclamation) End Sub
There's an updated copy of the Mind Map here: https://drive.google.com/file/d/0BwidG_nnMr5KcFdZSHVtaUJPMHM/view?usp=sharing

I now intend to work on the final piece
Sub Main
    ' Topics that one wishes to move have been selected
    ' With Selected objects
        ' Traverse up the tree to find a directory object
        ' Store the location of this directory to pass to XCOPY statement
        ' Return to the selected objects
            ' For each object
                ' Write of the desired XCOPY command
            'End
        ' End
    ' End
End Sub
Ok, will keep you all updated.

Best
/Eamonn
(Edited)
Photo of Nick Duffill

Nick Duffill, Champion

  • 515 Posts
  • 172 Reply Likes
If these topics are the ones created by the "File Explorer" smart map parts, then I think the data they create is stored in Custom Properties in the topic. You can find them in Topic.DataContainer.CustomProperties. I don't have any sample macrocode unfortunately.
Photo of Eamonn Edwardo

Eamonn Edwardo

  • 11 Posts
  • 2 Reply Likes
Thanks Nick, I'll take a look at what's being stored there.