Network Automation Software We are currently migrating this forum
over to our HelpSystems domain. Please
post all new threads in our new
HelpSystems Community Portal.
Post to the HelpSystems Forum
You are not currently logged on. You must be logged on in order to post. Log on
Or Create a new account
AutoMate Discussion
Decrease font size
Increase font size
Topic Title: counting files in a folder
Topic Summary: I need to count file in a folder but only a specific type
Created On: 06/09/2015 09:29 AM
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
View similar topics View similar topics
View topic in raw text format. Print this topic.
 06/09/2015 09:29 AM
User is offline View Users Profile Print this message

Author Icon
MaryWesterman
Journeyman (50-99)

Posts: 89
Joined: 08/18/2014

I have a file folder, and I need to count the number of .txt files within it.  There may be files with other extensions, I do not want to count those.  Then I need to rename the .txt files to processing.  I think I can rename all of them at one time.  Anyway,  here is what I am doing.  I cannot get it to count only the .txt files.  I've tried excluding, but it ignores anything I put in there.  How can I only count files with a certain extension?

<AMVARIABLE NAME="VarSource"></AMVARIABLE>
<AMVARIABLE NAME="VarFile"></AMVARIABLE>
<AMVARIABLE NAME="VarCount">0</AMVARIABLE>
<AMSET VARIABLENAME="VarSource">\\fw-app6n1-dev.portaldev.doitbestcorp.com\doitbest\data\vbn0350\Invoices\</AMSET>
<AMLOOP TYPE="FOLDER" FOLDER="%VarSource%" RESULTVARIABLE="VarFile">
     <AMINCREMENTVARIABLE RESULTVARIABLE="VarCount" />
</AMLOOP>

 

 



 Category Survey
AutoMate BPA Server 9 version: 9.0.5
Windows version: Windows Server 2012 R2
 06/09/2015 12:56 PM
User is offline View Users Profile Print this message

Author Icon
Alex Escalante
HelpSystems

Posts: 871
Joined: 02/26/2014

Hello Mary,

I would recommend using Get Information Activity from the File System action. You can populate a dataset that will contain all of the files within the folder and you can also get the total number of files in the folder by referencing dataset.totalrows. See the attached code as an example.

The attached code gets the total number of files in the c:\test folder and then loops the dataset that contains the file names of all files in the test folder.

You can use the exclude mask within the "get information" activity to exclude the files you don't want to be included or you can use a wildcard to include the files you want when choosing the folder path. For example c:\test\*.txt

 Category Survey



Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)


-------------------------

Alex Escalante | Support Analyst
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1.213.738.1700 | F: +1.213.738.7665
Statistics
18258 users are registered to the AutoMate Discussion forum.
There are currently 0 users logged in.
The most users ever online was 5551 on 01/08/2018 at 11:11 AM.
There are currently 1552 guests browsing this forum, which makes a total of 1552 users using this forum.

FuseTalk Enterprise Edition v4.0 - © 1999-2020 FuseTalk Inc. All rights reserved.

Sitemap Network Automation Software Blog