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: Just need the subfolder (noob, sorry)
Topic Summary:
Created On: 10/11/2012 05:27 PM
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.
 10/11/2012 05:27 PM
User is offline View Users Profile Print this message

Author Icon
PaulBell
n00b (>6 posts)

Posts: 3
Joined: 10/11/2012

 need to loop through a folder with lots of (often-changing) subfolders and find out a few things about the file.  Specifically, I need to find out the file's created date and time (got that easy) and the immediate subfolder it's in so I can later copy it to the same subfolder on an SFTP site.

Example: d:\folder\subfolder\thefile.txt <--all I want from this is the "subfolder" part

My first idea is to just try to ge the "Parent" property of the file I'm working with but that's giving me the whole path.

Is there a quick way to get just the immediate folder?  Can I take the whole path and somehow evaluate it to find what's to the right of the last \ character?

For that matter, is there a quicker or easier way to do what I need to do -- rename the source file with a DCN made from the date and time and a few  constants and upload it to the same subfolder on the SFTP site?

Here is my (obviously incomplete) script so far:

<AMTASK>
<AMTASKHEAD>
    <TASKINFO TASKVERSION="7120" />
</AMTASKHEAD>
<STEPS>
<AMVARIABLE NAME="strFileCreateTime"></AMVARIABLE>
<AMVARIABLE NAME="strStartDir">e:\sharedfiles\departments\medicare\applicationscan\drop_off</AMVARIABLE>
<AMVARIABLE NAME="strThisFile"></AMVARIABLE>
<AMVARIABLE NAME="intFileYear"></AMVARIABLE>
<AMVARIABLE NAME="intFileTime"></AMVARIABLE>
<AMVARIABLE NAME="strJulianDate"></AMVARIABLE>
<AMVARIABLE NAME="strDocType">M</AMVARIABLE>
<AMVARIABLE NAME="intIncrement">1</AMVARIABLE>
<AMVARIABLE NAME="strDCN"></AMVARIABLE>
<AMVARIABLE NAME="strWorkingFolder"></AMVARIABLE>
<AMLOOP TYPE="FOLDER" FOLDER="%strStartDir%" RESULTVARIABLE="strThisFile" SUBFOLDERS="YES" EXCLUDE="12*">
     <AMGETFILEINFO FILE="%strThisFile%" RESULTVARIABLE="strFileCreateTime" FILEPROPERTY="CreationTime" SUBFOLDERS="YES" />
     <AMGETFILEINFO FILE="%strThisFile%" RESULTVARIABLE="strWorkingFolder" FILEPROPERTY="Parent" />
     <AMTEXTFORMATDATETIME DATETIMEFORMAT="yy" 12HOURFORMAT="NO" RESULTVARIABLE="intFileYear" ACTION="specified" SPECIFIEDDATETIME="%strFileCreateTime%" SPECIFIEDFORMAT="m/d/yyyy h:nn:ss" />
     <AMTEXTFORMATDATETIME DATETIMEFORMAT="hhnnss" 12HOURFORMAT="NO" RESULTVARIABLE="intFileTime" ACTION="specified" SPECIFIEDDATETIME="%strFileCreateTime%" SPECIFIEDFORMAT="m/d/yyyy h:nn:ss" />
     <AMSET VARIABLENAME="strJulianDate">%DatePart("y",strFileCreateTime)%</AMSET>
     <AMINCREMENTVARIABLE RESULTVARIABLE="intIncrement" />
     <AMTEXTPAD TEXT="%intIncrement%" PADDINGCHAR="0" LENGTH="2" RESULTVARIABLE="intIncrement" />
     <AMSET VARIABLENAME="strDCN">%intFileYear&strJulianDate&strDocType&intFileTime&intIncrement%</AMSET>
     <AMMESSAGEBOX>DCN is %strDCN% and folder is %strWorkingFolder%</AMMESSAGEBOX>
</AMLOOP>
</STEPS>
</AMTASK>

 



 Category Survey
 10/12/2012 01:26 AM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

Paul,
hereunder two possible solutions

 Category Survey
AutoMate 7 version:
Windows version:



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


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 10/12/2012 11:48 AM
User is offline View Users Profile Print this message

Author Icon
PaulBell
n00b (>6 posts)

Posts: 3
Joined: 10/11/2012

Thanks.  You mention that there are two methods; which is which?  They seem to sort of run together to me...



 Category Survey
 10/12/2012 04:31 PM
User is offline View Users Profile Print this message

Author Icon
PaulBell
n00b (>6 posts)

Posts: 3
Joined: 10/11/2012

OK, I think I got it; "r1" is one way with the setup provided by the "v" and "p" variables; "r2" is the other way.

I ended up using the "r1" solution and it works fine.



 Category Survey
 10/13/2012 11:06 AM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

OK, Paul. You're welcome.

 Category Survey
AutoMate 7 version:
Windows version:


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
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 2187 guests browsing this forum, which makes a total of 2187 users using this forum.

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

Sitemap Network Automation Software Blog