How to copy files in a specific order to the correct location
Q: Here is the challenge:
- Copy job files (3 total) in a specific order to the correct location.
- There are 3 file formats:
- XML
- USF
- JPG
- The XML must be copied first, followed by the JPG and finally the USF.
Is this something you can help with?
A: Yes this would be possible with our tool. In version v2024.2.18.0 we added an option to achieve this.
Our idea is to use 3 Rules (tasks):
- Rule 1: Will copy the the files from the source into temporary subfolders with the name of the file without its extension.
- Rule 2: Will check if all three files are available and copy them in a specific order to the destination.
- Rule 3: Will do the cleanup of the temporary folders we used.
Rule 1:
- We used a Windows folder as source:
- “Filename Include Filter” is to only include xml, usf and jpg files:
- We enabled our file memory option so we’ll only handle the same source files once:
- Function is set to “Copy” so the original files stay at their source:
- As destination we used a Windows folder:
- This temporary Destination folder will be used in the ‘On Destination’ Pascal Script of Rule 2.
- We’ll copy the source files into subfolders with the name of the source file without its extension. This way a job consisting out of three files will reside with one subfolder.
Rule 2:
- The new option to achieve this request is available under our “Schedule Setup”. Switch to “Advanced” tab:
- Select ‘Root filepath & extension descending (Z to A) – Reset Exit Output on filepath change’
- Enable ‘Exit Output to Destination On Error’
- As source we used a Windows folder but important, the folder itself is a parameter, %VSA
- Don’t mind if it is marked red, this is because the parameter is empty during the setup.
- This %VSA parameter will be used in our ‘On Rule Begin’ Pascal Script option.
- Please open our ‘Pascal Script’ option:
- Enable and add the following ‘On Rule Begin’ Pascal Script:
- Please add the following script: link
- Don’t forget to adjust the ctScanPath Const. This path must be the same as the Destination folder of Rule 1.
- The script will scan the temporary root folder for subfolders, these subfolders are added to our psVSA var (= %VSA parameter).
- Enable and add the following ‘On Destination’ Pascal Script:
- Please add the following script: link
- This script will check if all three files (xml, usf and jpg) of a job are available.
- We enabled our file memory option int the second Rule also because we want to handle copy errors:
- Function is set to ‘Copy’:
- As Destination we also used a Windows folder:
- RunTime Log result:
- There is a missing file for Job ‘TestFile2’, so we’ll retry this one during the next scan.
- All three files are available for Job ‘TestFile’, so all three files are copied in the specific order as requested.
- Source folder of Rule 1:
- Destination folder of Rule 1:
- Destination subfolder of Rule 1:
- Destination subfolder of Rule 1:
- Destination folder of Rule 2:
Rule 3:
- Will handle the cleanup of the temporary folder we used: C:\Test\EDemo\Tmp
If you need any help with this ‘copy files in a specific order’ request, please let us know.
Best Regards,
Limagito Team
#managedfiletransfer #filetransfer #filemanagement