directory name

  • 08 Sep

    Query around filename to directory name

    Q: Query around filename to directory name. Reaching out just in case you have an easy way to assist for this one:

    We have a rule which currently picks up files from a SFTP source and drops them into an S3 bucket.

    Here are a sample of the source filenames:

    • (64506930) 87268700 20230826.pdf
    • (64506930) 87268701 20230826.pdf
    • (568454) 87282612 20230831.pdf

    This works, however we would like to drop them into a folder based on the {accountId} which is between the brackets:

    filename to directory name

    However we can’t rely on the filename begin and end positions as the accountId isn’t always the same length.

    Is there an easy answer to use a regex or something to select the accountId from between the brackets?
    Please let me know if you have any queries.

    A: In your Destination setup please adjust the ‘Create Subdir option’ to:   %SFN

    limagito file mover destination subdirectory option

    • Enable ‘Rename Destination Subdirectory’ and open ‘Rename Filter Setup’

    limagito file mover rename directory option

    • Directory Renaming Setup:
      RegEx:  \((.*)\)(.*)
      Replacements:   user/\1/invoices/

    filename to directory name

    • RunTime Log Result:

    limagito file mover runtime log result

    • Feedback Customer:

    Just a quick email to say thank you!  I only reach out to support occasionally – and each time I’m surprised at the level of support provided.

    If you need any info about this ‘filename to directory name’ request, please let us know.

    #mft #filetransfer #filemanagement

    Best regards,

    Limagito Team

    By Limagito-Team Rename
  • 01 Aug

    Q&A 22: move a file and rename the file so it includes the directory name

    Q: I’m trying to move a file that’s within 1 directory and rename the file so that it includes the directory name

    Source: C:\Source1\File.txt

    Destination: C:\Destination\Source1_File.txt

    I want it to take the directory name that it is contained in, then string it to the front of the filename, but move it to it’s destination C:\Destination\.

    We would only want it to pertain to the previous directory by 1 level.

    • C:\Source1\File1.txt => C:\Destination\Source1_File1.txt
    • C:\Source1\Sub\File2.txt => C:\Destination\Sub_File2.txt

    A: Yes this is possible using some ‘Pascal Script’

    Let’s start with the Source, we added a Windows folder:

    LimagitoX file Mover Windows Folder as Source

    In the ‘Directory Filter’ setup we enabled include scanning of subdirectories (optional, is not a must):

    LimagitoX file Mover Include Subdirectories

    Destinations setup, important the first destination must be a ‘Pascal Script’:

    LimagitoX file Mover Destination Setup

    First Destination should be a ‘Pascal Script’. We used ‘Source1’ as default PreFix for the Source Root Folder (you can adjust this):

    Var
      tmpPos: Integer;
      tmpSubDir: String;
    Const
      ctRootPrefix = 'Source1';
    Begin
      psExitCode:= 1;
      // ... add your code here
      psVSA := '';
      tmpSubDir := '%SFS';
      tmpPos := pos('\', tmpSubDir);
      If tmpPos<>0 Then
      Begin
        psVSA := Copy(tmpSubDir, tmpPos + 1, Length(tmpSubDir) - tmpPos);
        psLogWrite(1, '', 'Stripped Prefix from SubDir: ' + tmpSubDir + ' : ' + psVSA);  
      End
      Else
        psVSA := ctRootPrefix;   
    End.

    LimagitoX file Mover Pascal script

    Second Destination is a windows folder where the source files should be moved/copied to:

    LimagitoX file Mover Windows Folder as Destination

    Enable and setup File Renaming in the Windows Destination:

    LimagitoX file Mover File Renaming

    File Renaming setup:

    • RegEx:   (.*)
    • Replacement:   %VSA_\1

    LimagitoX file Mover File Renaming Setup

    RunTime Log result:

    LimagitoX file Mover RunTime Log

    Output Folder result:

    If you need any help , please let us know.
    Regards,
    Limagito Team
    By Limagito-Team Q&A ,
SEARCH