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:
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:
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’ :
- Next we’ll need to add a ‘Pascal Script’ to strip data from the csv file and use it as directory filter:
- 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.
- Directory filter setup:
The %VSA (= Var String A) configured by the previous script will be used as ‘Directory Name Include Filter’:
This ‘Allow parameters in Directory Name Filter’ option should be enabled by default:
- As Destination we used a Windows folder:
- 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.