Page 1 of 1

Ignore files in root dir

Posted: Tue Oct 02, 2012 3:54 pm
by LPrendergast
Hi All, I have a directory with several subdirectories and files in it. I want to be able to retrieve files from the subdirectories while excluding all files in the root directory, how can Ido this? see below for example
the black text are the directories and the blue text are the files, these are all under the same parent directory.
How can exclude just the files in blue?


850_061665964NC 10/2/12 5:41:00 PM 0
852_061665964NC 10/2/12 5:41:00 PM 0
EDI_INVRPT_D_01B_UN_EAN006_1 10/2/12 5:41:00 PM 0
EDI_INVRPT_D_96A_UN_EAN004_1 10/2/12 5:41:00 PM 0
EDI_ORDERS_D_93A_UN_EAN007_1 10/2/12 5:41:00 PM 0
EDI_ORDERS_D_96A_UN_EAN008_1 10/2/12 5:41:00 PM 0
EDI_ORDERS_D_96A_UN_EAN008_42 10/2/12 5:41:00 PM 0
EDI_SLSRPT__901_EN_EAN001_1 10/2/12 5:41:00 PM 0
EDI_SLSRPT_D_93A_UN_EAN003_1 10/2/12 5:41:00 PM 0
EDI_SLSRPT_D_96A_UN_EAN004_1 10/2/12 5:41:00 PM 0
EDI_SLSRPT_D_96A_UN_EAN004_1_RINASCENTE 10/2/12 5:41:00 PM 0
EDIWIN-SOURCE-FILE 10/2/12 5:41:00 PM 0
1209261628020193972000-061665964NC-852_061665964NC-0 10/2/12 5:39:00 PM 12.76
1209261628095702694000-061665964NC-852_061665964NC-0 10/2/12 5:39:00 PM 1.58
1209261828352132171000-061665964NC-850_061665964NC 10/2/12 5:38:00 PM 2.75
1209271828442097749000-061665964NC-850_061665964NC 10/2/12 5:38:00 PM 4.3
1209281430099632668000-061665964NC-852_061665964NC-0 10/2/12 5:39:00 PM 13.99

Re: Ignore files in root dir

Posted: Tue Oct 02, 2012 6:09 pm
by Support_Rick
Here is one way you can do this:

Just change the "InboundFolder" variable at the end of this script to the folder you want to read (recursive). This will read all files in the InboundFolder and below... but, only print the status of the files that are not in the InboundFolder.
Code: Select all
<project name="RootFile Test" mainModule="Main" version="2.0" threadSafe="false">

	<module name="Main">

		<createFileList label="Get Local FileList" fileListVariable="FilesToProcess" numFilesFoundVariable="NoFilesToProcess" version="1.0">
			<fileset dir="${ InboundFolder }" recursive="true">
				<wildcardFilter>
					<include pattern="*" caseSensitive="false" />
				</wildcardFilter>
			</fileset>
		</createFileList>

		<forEachLoop label="Process Files Found" itemsVariable="${FilesToProcess}" currentItemVariable="ThisFile">

			<setVariable label="RootFolderFile" name="RootFolderFile" value="${ Concat( InboundFolder, &apos;\&apos;, ThisFile:name ) }" version="1.0" />

			<print label="Compare" version="1.0">
        <![CDATA[
================================================================================
** File Path Compare **
${ RootFolderFile }
${ ThisFile:path }
================================================================================
          ]]>
			</print>

			<if condition="${ ThisFile:path ne RootFolderFile }">
				<print label="Not in Root Folder" version="1.0">
					<![CDATA[
================================================================================
** This file is not in the Root Folder **
${ ThisFile:path }
================================================================================
          ]]>
				</print>
			</if>

		</forEachLoop>
	</module>

	<variable name="InboundFolder" value="C:\MyFolder" description="Root Folder to Read" />

	<description>Check to see if file is in Root Folder</description>

</project>
If you have any questions ... please let us know!