Pascal Script

  • 19 Nov

    How to move files based on data from a csv file

    How to move files based on data from a csv file

    Q: I have the Limagoto X software installed, and I would like to know if it’s possible to move files, based on some information from a csv file? I have an csv file with some order numbers, and the folders I want to move, are label with these order numbers.

    A line in the csv file would look like this:

    The file structure looks like this:

    limagito file mover folder structure example

    So I would have to extract “D” first letter of “Donald Duck” -> then look in folder “Donald Duck”\ordre and search for 9999999 and move that folder to a new location with the same folder structure.

    A: We asked and received a dummy csv file, data content lookes like:

    Art;Ordrenr.;Arkiveret;Arkivdato;Jobnavn;Kundenavn;Statuskode;Ordretype;S‘lger;Ordrestyrer
    Ordre;9876543;SAND;17-11-2023;Arkiveringstest;Limagito Complete;AABEN_ARKIV;ARK;TEAM-E;MHOE

    So in this example:

    • We would strip the first char of the ‘Kundenavn’ field:  L
    • Next it would be the full name of the same ‘Kundenavn’ field:  Limagito Complete
    • Add fixed text:  Ordre
    • And finally the value of data field ‘Ordre’:  9876543

    Result as Directory filter: *\L\Limagito Complete\Ordre\9876543\*

    • As source we used a Windows folder, root folder to start from is ‘Jobs’ :

    limagito file mover windows folder as source

    • Next we’ll need to add a ‘Pascal Script’ to strip data from the csv file and use it as directory filter:

    limagito file mover pascal script option

    • Enable and add the following ‘On Rule Begin’ Pascal Script:

    You can download the script: here

    Do not forget to adjust the ctDataPath const (must end with a \ ). In this path we’ll search for .csv data file(s) with a date structure in its filename like ‘YYYY-MM-DD’. This can, of course, be adjusted.

    limagito fil emover move files based on data from a csv file

    • Directory filter setup:

    limagito file mover directory filter setup

    The %VSA (= Var String A) configured by the previous script will be used as ‘Directory Name Include Filter’:

    limagito file mover directory filter

    This ‘Allow parameters in Directory Name Filter’ option should be enabled by default:

    limagito file mover directory filter

    • As Destination we used a Windows folder:

    limagito file mover windows folder as destination

    • RunTime log result:

    limagito file mover runtime log result

    #csv #managedfiletransfer #filetransfer #filemanagement

    If you need any help with this ‘move files based on data from a csv file’ request, please let us know.

    Best Regards,

    Limagito Team

  • 12 Nov

    How to merge and add filenames to csv datafiles

    How to merge and add filenames to csv datafiles

    Q: I have a new daily job where I will receive 3 CSV files. I need to merge these together and also add a new field to the data that contains the original filename as I need to split them later on in the process and use the original filename to send back to the client. Also, I may not always get all 3 files so the rule needs to work for receiving 1,2, or all 3 files.

    We will run the rule at 18:00 for example and process however many files have been uploaded, then run the rule every 1 hour after to pick up any files that the client has uploaded late. The ideal scenario would be for all 3 files to be uploaded by the client by the scan time, but they want us to be able to pick up any files they may upload late.

    The data does not contain headers either. I’m sure I have asked this before but I can’t find the solution if I have, I have found similar and have tried to amend it to suit but failed miserably.

    A: We asked and received the following example files:

    • BTW_Invites_20231023_1.csv
    • BTW_Reminders_20231023_1.csv
    • BTW_Results_20231023_1.csv

    We used a Windows folder as Source:

    limagito file mover windows folder as source

    We added the following ‘Include Filename’ Filter because we want to be sure to only process .csv files:

    limagito file mover filename filter setup

    As Destination we add our ‘Pascal Script’ option:

    limagito file mover destination setup

    Destination Pascal Script, do not forget to adjust the ctOutputPath const (Path must end with a \ ).

    The script will add the filename of the source csv file to the end of each entry of the merged csv file. The Destination merged csv file is determined by stripping parts of the source filename. In our example it will be: ‘BTW_Merged_20231023_1.csv’.

    This script is just an example and it can be adjusted so it fits your needs, just let us know.

    You can download the script: here

    limagito file mover merge and add filenames script

    RunTime Log Result:

    limagito file mover runtime log result

    #csv #filetransfer #filemanagement

    If you need any help with this ‘merge and add filenames’ option, please let us know.

    Best Regards,

    Limagito Team

  • 05 Nov

    How to setup a rule that reads a list of folders from a file

    How to setup a rule that reads a list of folders from a file

    Q: I wonder can you help me. I have a Source folder with hundreds of subfolders, each with a 5-digit numeric name –
    c:\source\23432, c:\source\76453 – you get the idea

    Inside each subfolder is a list of .txt and/or .inp files. – that’s kind of irrelevant.

    I’m trying to setup a rule that reads a list of folders from a file, one per line

    I want the rule to move t or copy the contents of just those subfolders to a destination which will also have the entry from the file somewhere in the destination path – e:\destinatio\<foldername>\target for eample

    I’ve tried use %FSA in various ways, but I’m hitting a brick wall. Any ideas?

    Limagito: Could you send me an example of such a file which contains the folders to copy

    It’s as simple as these  – so the source folders would, for example, be c:\source\<linefromfile> and the destination would be e:\dest\<linefromfile>

    list of folders from a file

    List of folders from a file\list of folders from a file

    Limagito: ok both text files are just examples I guess. Th text file to read from would always have the same name or would there be multiple txt files?

    For each rule, the text file will always be the same – one text file per job. The contents of each source folder however will change

    A: This is possible using a custom script.

    • We are using a Windows folder as source.

    limagito file mover windows folder as source

    • This folder contains subfolders, each with a 5-digit nummer.

    limagito file mover test folder setup

     

    • Please open our ‘Pascal Script’ option:

    limagito file mover pascal script option

    • Please enable and add the following ‘On Rule Begin’ Pascal Script. Don’t forget to adjust the ctTxtFile const. The script will read the content of the external text file and will set to our %VSA variable. This %VSA variable will be used in the Directory setup later.

    You can download the script: here

    limagito file mover pascal script option

    • The Directory Filter setup is very important in this case:
      • Enable ‘Include Subdirectories’
      • ‘Exclude Basedirectory’, because we only are interested in the content of the subfolders
      • Set ‘Subdirectory Filter Depth’ to ‘1’. Only the first level folder name is the one that will be used to check if it exists in the txt file.

    limagito file mover directory filter setup

    • Switch to the ‘Dir Name’, ‘Include’ tab:
      • Add  %VSA  as Directory Include Filter

    limagito file mover directory filter setup

    • Switch to ‘Advanced’ tab:
      • Set ‘SubDir Search Mode (WIN) to ‘Exclude Complete Invalid SubDirs’
        • The reason is that we will not scan invalid subfolders. So, if we can not find the folder name (5-digit numeric name) in the external text file, we’ll skip the subfolder completely.

    limagito file mover directory filter setup

    • We used a Windows Folder as Destination with default setup options:

    limagito file mover windows folder as Destination

    limagito file mover windows folder as destination setup

    limagito file mover windows folder as destination setup

     

    • RunTime log result:

    limagito file mover runtime log result

    • Destination output result:

    limagito file mover test folders

    #filetransfer #filemanagement

    If you need any help with this ‘list of folders from a file’ request, please let us know.

    Best Regards,

    Limagito Team

1 2 3 4 5 6 7 26
SEARCH