Rename

  • 12 Nov

    Regular expressions reference guide

    Regular expressions reference guide

    ANCHORS

    ^         Match the start of a string
    $         Match the end of a string
    \b        Match a word boundary
    \B        Match a non-word boundary

    ANCHORS Examples

    ^Hello    Matches "Hello world" but not "Say Hello"
    world$    Matches "Hello world" but not "world peace"
    \bcat\b   Matches "cat" in "the cat sat" but not in "category"
    \Bcat     Matches "cat" in "category" but not in "the cat"
    \bcat     Matches "cat" at word start: "cat" and "category"
    cat\b     Matches "cat" at word end: "cat" and "tomcat"

    CHARACTER SETS

    [xyz]     Match any of x, y or z
    [^xyz]    Match anything except x, y or z
    [0-9]     Match any digit
    [a-z]     Match any lowercase letter

    CHARACTER SETS Examples

    [aeiou]   Matches any vowel
    [^aeiou]  Matches any consonant (non-vowel)
    [0-9]     Matches "5" in "Hello5"
    [a-zA-Z]  Matches any letter (upper or lower)
    [a-z0-9]  Matches any lowercase letter or digit
    gr[ae]y   Matches both "gray" and "grey"
    [^0-9]    Matches any non-digit character

    ESCAPE CHARACTERS

    \.        Matches a literal period/dot character
    \d        Matches any digit (0-9)
    \s        Matches any whitespace (space, tab, newline)
    \w        Matches any word character (a-z, A-Z, 0-9, _)
    \D        Matches any non-digit
    \S        Matches any non-whitespace
    \W        Matches any non-word character

    ESCAPE CHARACTERS Examples

    192\.168\.1\.1   Matches IP address (dots are literal)
    \d{3}            Matches "123" in "Room 123"
    Hello\sWorld     Matches "Hello World" or "Hello World"
    \w+              Matches "hello", "test123", "my_var"
    \d+\.\d+         Matches decimal numbers like "3.14" or "99.99"
    \w+@\w+\.\w+     Matches simple email pattern

    FLAGS / MODIFIERS

    i         Case-insensitive matching
    g         Global match (find all matches)
    m         Multiline mode (^ and $ match line breaks)
    s         Dotall mode (. matches newline)

    FLAGS / MODIFIERS Examples

    Case-insensitive (i):
    /hello/ Matches only “hello”
    /hello/i Matches “hello”, “Hello”, “HELLO”, “HeLLo”

    Global (g):
    /cat/ Matches first “cat” in “cat and cat”
    /cat/g Matches both “cat” instances

    Multiline (m):
    Text: “Line 1\nLine 2\nLine 3”
    /^Line/ Matches only first “Line”
    /^Line/m Matches all three “Line” at start of each line
    /\d$/m Matches digit at end of each line

    Dotall (s):
    Text: “Hello\nWorld”
    /Hello.World/ No match (. doesn’t match \n)
    /Hello.World/s Matches (. now matches \n)

    Combined flags:
    /test/gi Case-insensitive AND global
    /^start/mi Multiline AND case-insensitive

    GREEDY vs LAZY

    *         Greedy: match as much as possible
    *?        Lazy: match as little as possible
    +         Greedy
    +?        Lazy
    ?         Greedy
    ??        Lazy
    {n,m}     Greedy
    {n,m}?    Lazy

    GROUPS

    (xyz)     Match 'xyz' as group
    (x|y)     Match 'x' or 'y'
    (?=xyz)   Match succeeds only if followed by xyz
    (?!xyz)   Match succeeds only if not followed by xyz

    GROUPS Examples

    (cat|dog)        Matches "cat" or "dog"
    (\d{3})-(\d{4})  Matches "555-1234" (captures area code and number separately)
    (https?://)?     Matches optional "http://" or "https://"
    test(?=ing)      Matches "test" in "testing" but not in "tester"
    test(?!ing)      Matches "test" in "tester" but not in "testing"
    \d+(?=px)        Matches "10" and "20" in "10px 15em 20px"
    \$\d+(?!\.)      Matches "$50" but not "$50.99" (whole dollars only)

    GROUPS References (BACKREFENCES)

    \1        Reference to first captured group
    \2        Reference to second captured group

    SPECIAL CHARACTERS

    \t        Tab character
    \n        Newline
    \r        Carriage return
    \\        Literal backslash
    \*        Literal asterisk
    \+        Literal plus
    \?        Literal question mark

    SPECIAL CHARACTERS Examples

    \t           Matches tab in "Hello\tWorld"
    \n           Matches newline in multi-line text
    Price: \$50  Matches "Price: $50" (literal dollar sign)
    C:\\Users    Matches "C:\Users" (literal backslash)

    QUANTIFIERS

    ?         Match 0 or 1 time (optional)
    *         Match 0 or more times
    +         Match 1 or more times (at least once)
    {n}       Match exactly n times
    {n,}      Match n or more times
    {n,m}     Match between n and m times

    QUANTIFIERS Examples

    a?        Matches "" or "a"
    a*        Matches "", "a", "aa", "aaa", etc.
    a+        Matches "a", "aa", "aaa", etc. (but not empty)
    a{3}      Matches exactly "aaa"
    a{2,}     Matches "aa", "aaa", "aaaa", etc.
    a{2,4}    Matches "aa", "aaa", or "aaaa"

    If you need any help about this ‘Regular expressions reference guide’, please let us know.

    Best Regards,

    Limagito Team

    #regex #managedfiletransfer #filetransfer #filemanagement

    By Limagito-Team Rename ,
  • 05 Oct

    How to add a timestamp to the original filename

    How to add a timestamp to the original filename

    Q: Original filename from the source is SOHF_JC_18092025.csv. We need it to rename to SOHF_JC_18092025_HHMMSS.csv. We need to add a timestamp to the original filename. For example, from SOHF_JC_18092025.csv to SOHF_JC_18092025_153303.csv

    A: Yes, possible using our file rename option in your Destination setup.

    RegEx:   (.*)\.(.*)
    Replace:    \1_%TCD:HHNNSS:.\2

    limagito file mover add a timestamp

    If you need any help about this ‘add a timestamp’ request, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

    By Limagito-Team Rename
  • 10 Jul

    How to rename files and add the folder name on each file

    How to rename files and add the folder name on each file?

    Q: I was wondering if you could help me.

    I did do quite a bit of searching over the last few days trying to find a solution, and just couldn’t get it worked out.

    I have a lot of folders with PDFs in them.

    The folders are named:
    01-01-2025
    01-02-2025

    and so forth. Each folder has a number of PDFs in them, named as:

    A1.pdf
    A2.pdf
    A3.pdf
    A10.pdf

    and so forth. Each folder has a number of PDFs and they are all identically named, as in letter number.pdf.

    Can you help me get a set up where, if I drop a folder in a source folder, Limagito processes the and puts the folder name on each file, as in

    20250102_A_0001.pdf
    20250102_A_0002.pdf

    and

    20250102_B_0001.pdf

    and

    20250102_A_0010.pdf
    20250102_A_0011.pdf

    and so forth. This would be a move, with the files going into a folder with the same name as the original, if possible.

    This would be really huge if you could help me. I probably have 15 years of folders that need to be processed, for about 20 publications.

    We are trying to send a lot of archives to newspapers.com, and this is the naming convention they prefer.

    If there is anything else you need from me please let me know. Thank you in advance for any help.

    A: Yes this is possible using our Destination file rename option:

    • Windows Folder as Source. Root folder in our case is C:\Test\In_PDF\

    limagito file mover windows folder as source

    • File Filter setup, we only want to handle pdf files in our example:

    limagito file mover filename include filter

    • Directory Filter setup: we only want to handle files within subdirectories one level deep:

    limagito file mover directory filter setup

    • Move Files, during the test we used Copy Files:

     

    limagito file mover function setup

    • Windows folder as Destination:

    limagito file mover destination setup

    • Destination Rename Files:

    limagito file mover file rename setup

    • Rename Files Setup:

    limagito file mover file rename setup

    (.)(\d\d\d\d)\.(.*)
    %SFS:7-10:%SFS:1-2:%SFS:4-5:_\1_\2.\3
    CEM
    (.)(\d\d\d)\.(.*)
    %SFS:7-10:%SFS:1-2:%SFS:4-5:_\1_0\2.\3
    CEM
    (.)(\d\d)\.(.*)
    %SFS:7-10:%SFS:1-2:%SFS:4-5:_\1_00\2.\3
    CEM
    (.)(\d)\.(.*)
    %SFS:7-10:%SFS:1-2:%SFS:4-5:_\1_000\2.\3
    CEM

     

    • RunTime Log Result:

    limagito file mover runtime log

    • Source folders used during this test:

    limagito file mover folder name on each file

    limagito file mover folder name on each file

    limagito file mover folder name on each file

    Feedback from customer:

    OMG… thank you so much. You guys are awesome.
    I’ve tested it and it works perfectly.
    I think this will probably help me with some other files that have single and double digit page numbers.
    You have my deepest appreciation.

    If you need any help with this ‘folder name on each file’ question, please let us know.

    Best Regards,

    Limagito Team

    #regex #managedfiletransfer #filetransfer #filemanagement

    By Limagito-Team Rename
1 2 3 4 6
SEARCH