6979faefbacb4dee06d02fb1aad9714d

File Transfers into sub-directories

Discussion created by 6979faefbacb4dee06d02fb1aad9714d on Apr 28, 2015
Latest reply on Jul 3, 2018 by ShashankSingh606566
Hi All, this is my first post, but I've recently stepped into the role of a UC4 admin at my company. So far, it seems like a really amazing piece of software so I'm looking forward to learning more about it.

Currently, I'm attempting to write a script which will look in a directory and transfer the files from it to sub directories on a different agent based on sub-strings within the file names.

For an example, I have directory C:\pictures which has two files in it, p0576410.jpg and p0871254pic.jpg. I'm writing a script which will move these files into sub-directories (on a different agent) C:\pictures\057 and C:\pictures\087 so I'm using the 2-4 character strings of the file names. The script needs to look at the 2-4 characters and then move the file into the subdir automatically, if the subdir doesn't exist then it needs to create it according to the 2-4 character string. It will always be the 2-4 character string also.

At this point, I have figured out how to create the script such that it will only take the 2-4 character string by using the MID() command. And I know that in using a file transfer object, I can put in the destination path, the variable I'm using to define the substring (so in the destination path for JOBF, I can put C:\pictures\&substring# but what my script seems to do is us the very last substring and only create a subdir based on that.

So going back to my previous example, it would just create C:\pictures\087 and then put both files in that subdir.

Here is my code so far: (For reference, VARA.FILELIST.MRA, is a list of file names exactly like the one in my previous example, but there are 9)

:  DEFINE &pnum#, String
:  set &fid# = PREP_PROCESS_VAR(VARA.FILELIST.MRA)
:  PROCESS &fid#
:  SET &file# = GET_PROCESS_LINE(&fid#)
:  PRINT &file#
:  SET &pnum# = MID(&file#, 2,4)
:  PRINT "NEXT LINE IS PNUM"
:  PRINT &pnum#
:ENDPROCESS

This is in the "process" tab of a JOBF object, fyi, and in the destination path, it is C:\pictures\&pnum. It's almost like I need to loop it so that it transfers each file individually, but I can't imagine that's right let alone how I could do that...

Any help would be much appreciated!


Outcomes