Here's a macro to split file name into parts...

Help with writing and playing macros

Here's a macro to split file name into parts...

Postby bobh » Wed Dec 29, 2004 9:44 am

Found a temporary workaround for my problem. It doesn't give me project file paths or names, but at least this will let me more easily pick the parts out of the path I am interested in.

What it does is copy the full path and name of the file currently open to a new file and split it apart at the backslash. It retains the period before the extension which makes it easier to find -- well, as long as you don't have periods embedded in the file name, that is. But it is a pretty good quick-n-dirty hack:

Code: Select all
    InsertMode      ; standard macro settings
    ColumnModeOff   ;
    HexOff          ;
    UnixReOff       ; --
    Clipboard 1     ; change to another clipboard
    CopyFilePath    ; copy file path and name
    NewFile         ; open a new file
    Paste           ; insert copied file name
    Top             ; go to beginning of page
    Loop            ; --
    Find "\"        ; split the line at each backslash
    IfFound         ;
    "               ;
    "               ;
    Else            ;
    ExitLoop        ;
    EndIf           ;
    EndLoop         ; --
    StartSelect     ; delete up to the dot
    Find "."        ;
    IfFound         ;
    Key LEFT ARROW  ;
    EndSelect       ;
    Delete          ;
    EndIf           ; --
    ClearClipboard  ; empty user clipboard 1
    Clipboard 0     ; restore previous (Windows) clipboard


If the project name is also part of the path, you can easily find it by position. Of course, this entails following some kind of convention (as I do) for directory structures in your project.

The default properties for the macro should be:

UNCHECKED - Show Cancel Dialog for this macro
CHECKED - Continue if a Find with Replace not found

Hope you may find this as useful as I did!
User avatar
bobh
Advanced User
Advanced User
 
Posts: 59
Joined: Tue Dec 28, 2004 12:00 am

Return to Macros