Page 1 of 1

Moving files from a list of files

Posted: Thu Jun 18, 2015 9:13 am
by EdWyche
II have a list of files that are read in using the Create File List task. I loop through the files to send them out after the are sent out I want to check part of the filename and it equals that part move it to another folder. If it does not equal part of that filename skip it and leave the files where it is at. Any suggestions would be appreciated.

Re: Moving files from a list of files

Posted: Fri Jun 19, 2015 2:05 pm
by Support_Julie
Inside your loop, set a variable for the file name.
Then add an IF statement to check for the substring.
If the substring exists, then you can move it.
I have attached a simple project that checks for a file name that starts out with "Linoma".

Code: Select all
<project name="checkFileName" mainModule="Main" version="2.0">

	<module name="Main" logLevel="debug">

		<createFileList fileListVariable="fileList" numFilesFoundVariable="fileCount" version="1.0">
			<fileset dir="/MyFolder/" />

		<forEachLoop itemsVariable="${fileList}" currentItemVariable="thisFile">

			<setVariable label="MyFileName" name="MyFileName" value="${thisFile:nameWithoutExtension}" version="1.0" />

			<if condition="${(Substring(MyFileName, 1, 6) == &apos;Linoma&apos;)}">

				<print version="1.0">
the file contained the string
this is where you would add your copy/move file task



Re: Moving files from a list of files

Posted: Wed Jun 24, 2015 2:43 pm
by EdWyche
This worked great thank you.