Intelligent Automation & Macro Software  

Go Back   Tethys Solutions Forums > Products Zone > Automation Anywhere
Register FAQ Search Today's Posts Mark Forums Read

Automation Anywhere Post messages and questions related to Automation Software here.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-05-2007, 06:55 PM
Andy Sterner Andy Sterner is offline
Junior Member
 
Join Date: Jul 2007
Location: Brooklyn
Posts: 7
Default Loop for "$foldername$"

I'm trying to write a loop to add a subfolder "Originals" in each folder in the current folder.

It works if I use a Loop statement naming the current folder, as for instance

Loop for "Each folder in c:\temp\temp1"

But I want to be able to use it in whatever folder I happen to be in. I've tried

Loop for "Each folder in $CurrentDirectory$"

with no success. What am I doing wrong?
__________________
--Baffled in Brooklyn

Last edited by Andy Sterner; 07-06-2007 at 06:09 AM. Reason: change signature
Reply With Quote
  #2 (permalink)  
Old 07-06-2007, 06:04 AM
Andy Sterner Andy Sterner is offline
Junior Member
 
Join Date: Jul 2007
Location: Brooklyn
Posts: 7
Default

In my earlier message, I gave the code examples from memory. This may lead the reader to think I've made syntactical errors I haven't. Here's a sample of the code that doesn't work:

Quote:
Start loop "Each Folder in $CurrentDirectory$\$foldername$"
where $foldername$ is supposed to return the folder in which I'm starting the task and $CurrentDirectory$ is supposed to return the path to it.

Please forgive me for asking a question I'm sure shows my ignorance. I've only begun working with Automation Anywhere 3.5, or indeed with any version of any Tethys product.

I do, however, do fairly sophisticated stuff with WordPerfect macros, and elementary stuff with VBA.
__________________
--Baffled in Brooklyn
Reply With Quote
  #3 (permalink)  
Old 07-06-2007, 06:22 AM
forumsupport forumsupport is offline
Senior Member
 
Join Date: Apr 2007
Posts: 1,311
Default

Hello Andy,

You are doing no wrong. The code you sent us is perfectly fine. What we understand is that you want to choose the folder i.e you want the task to prompt you for the folder name under which you want to create folder named 'Originals' in 'Every Folder in a Folder'. Right? What you can do is use 'Prompt' command that will prompt you to enter the folder name and you can assign that value to a variable, say $variable1$ and use this in loop command as follows

To create folder named 'Originals' in 'Every Folder in a Folder' you can do as follows:

1 Start Loop " Each Folder in C:\dir1\$variable1$"
2 Create Folder "$CurrentDirectory$\$FolderName$\ORIGINALS"
3 Delay: (200 ms)
4 End Loop

Doing above steps, it will create folder named 'Originals' in every folder under folder that you provide.

And, $foldername$ and $currentdirectory$ variables work only inside the loop command. You cannot use these variables as a part of loop statement itself.

Hope that helps.
Reply With Quote
  #4 (permalink)  
Old 07-06-2007, 07:32 AM
Andy Sterner Andy Sterner is offline
Junior Member
 
Join Date: Jul 2007
Location: Brooklyn
Posts: 7
Default

So let me make sure I understand:

Each time I run the task, I have to type in the full pathname and folder name of the folder on whose constituent folders I want it to run.

There is no way I can set up the task so I can open Explorer to the folder I want, which may be any of several, and there run the task on the subfolders in it, without--once I click the task icon--any further input.

It's impossible to write a loop for files or folders without tying it to a specific folder.

I wonder if there's any way to capture the folder name and path from the screen and put it into the variable, automatically? Anyone got any ideas?
__________________
--Baffled in Brooklyn
Reply With Quote
  #5 (permalink)  
Old 07-06-2007, 07:40 AM
forumsupport forumsupport is offline
Senior Member
 
Join Date: Apr 2007
Posts: 1,311
Default

Hello Andy,

To avoid roundtrips you can call us and we will certainly help you resolve the query. You can reach us at 1-888-484-3535 x 3. Alternatively, if you can email your contact number at http://www.tethyssolutions.com/support_form.htm then we can also call you.

Last edited by forumsupport; 10-29-2007 at 03:44 AM.
Reply With Quote
  #6 (permalink)  
Old 07-06-2007, 02:47 PM
Andy Sterner Andy Sterner is offline
Junior Member
 
Join Date: Jul 2007
Location: Brooklyn
Posts: 7
Default

Thanks so much. I'm emailing you my phone number, but right now I think I've reached a workaround.

To capture the folder's name and its full path, and make it a variable, I've decided to start the task anyplace in the window of Windows Explorer, open to the folder in question. Because I think this provides a general solution, I've made the capture process a separate task, to be called from any other macro needing a path-and-foldername.

It uses Alt-D to highlight the path-and-foldername in the address field, and copy it. Then it pastes it to a new page in Notepad, which it saves as VarStore.txt.

Here's the text:

Quote:
1 Keystrokes: [ALT DOWN][TAB][ALT UP] in "Currently Active Window"
2 Keystrokes: [ALT DOWN]d[ALT UP][CTRL DOWN]c[CTRL UP] in "Currently Active Window"
3 Open "Notepad.exe "
4 Keystrokes: folderpathandname=[CTRL DOWN]v[CTRL UP] in "Untitled - Notepad"
5 Delay: (50 ms)
6 Keystrokes: [ALT DOWN]f[ALT UP]a in "Currently Active Window"
7 Keystrokes: c:\VarStore.txt[ENTER] in "Save As"
8 Delay: (50 ms)
9 Keystrokes: y in "Currently Active Window"
10 Delay: (50 ms)
11 Keystrokes: [ALT DOWN]f[ALT UP]x in "Currently Active Window"
Some interesting points: when I start the task the focus is on Windows Explorer, but the act of starting the task takes that focus away. By trial and error I discovered that beginning the routine with Alt-Tab put the focus back where it belonged.

I used the FullFolderName task in ClickHere, which inserts a "Click Here." bookmark in every PDF file in a particular directory. It works, though the test files I've used are only a few pages. I tried putting in "Wait for Window" commands but "Adobe Acrobat Professional - [*.pdf]" doesn't work as a Window Name, and I had to fall back on "Currently Active Window", which won't help me wait until a file is fully opened or fully saved. Using a "Wait for X Seconds" command is useless, because some files save instantly and some take ten minutes, depending on their size and how recently they've been saved before.

Here's the text:

Quote:
1 Comment: Run from Windows Explorer, in desired folder.
2 Run Task "C:\My Documents\Automation Anywhere\Automation Anywhere\My Tasks\FolderFullName.atmn" @Repeat : Do Not Repeat @Speed : Turbo Speed
3 Open "C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe "
4 Wait for Window to Open ("Adobe Acrobat Professional") (Wait up to 60 seconds - for Window to Open)
5 Start Loop " Each File in $folderpathandname$"
6 Comment: Please enter your commands to loop. Use $filename$ variable for each file name in the Loop.
7 Keystrokes: [CTRL DOWN]o[CTRL UP] in "Adobe Acrobat Professional"
8 Wait for Window to Open ("Open") (Wait up to 2 seconds - for Window to Open)
9 Keystrokes: $folderpathandname$\$FileName$.pdf in "Open"
10 Keystrokes: [ENTER] in "Open"
11 Keystrokes: [CTRL DOWN]b[CTRL UP][SHIFT DOWN]c[SHIFT UP]lick [SHIFT DOWN]h[SHIFT UP]ere.[TAB][CTRL DOWN]s[CTRL UP] in "Currently Active Window"
12 Keystrokes: [CTRL DOWN]w[CTRL UP] in "Currently Active Window"
13 End Loop
I'm attaching the ATMN files if you want to try them. You'll need to have c:\VarStore.txt already in existence, because of the "y" in answer to the overwrite query.

I'm also attaching Originals.atmn, which solves the problem stated at the start of this thread. It was a lot easier than ClickHere.atmn.
Attached Files
File Type: atmn FolderFullName.atmn (8.4 KB, 3 views)
File Type: atmn ClickHere.atmn (5.9 KB, 1 views)
File Type: atmn Originals.atmn (667 Bytes, 1 views)
__________________
--Baffled in Brooklyn

Last edited by Andy Sterner; 07-06-2007 at 03:06 PM.
Reply With Quote
  #7 (permalink)  
Old 07-06-2007, 05:03 PM
Andy Sterner Andy Sterner is offline
Junior Member
 
Join Date: Jul 2007
Location: Brooklyn
Posts: 7
Default Easier Way

Of course, there's an easier way to capture the path to a variable. Silly me, I kept looking for an Assign command. But there it was, hiding under Clipboard. So:
Quote:
1 Keystrokes: [ALT DOWN][TAB][ALT UP] in "Currently Active Window"
2 Keystrokes: [ALT DOWN]d[ALT UP][CTRL DOWN]c[CTRL UP] in "Currently Active Window"
3 Assign value of Clipboard to variable "$folderpathandname$
I'm attaching a replacement ATMN file containing the foregoing.
Attached Files
File Type: atmn FolderFullName.atmn (2.2 KB, 4 views)
__________________
--Baffled in Brooklyn
Reply With Quote
  #8 (permalink)  
Old 07-06-2007, 11:13 PM
Andy Sterner Andy Sterner is offline
Junior Member
 
Join Date: Jul 2007
Location: Brooklyn
Posts: 7
Default Drat!

Spoke too soon. The code in FolderFullName.atmn works fine, but when you Run it from another task, something seems to go wrong in passing the variable from the one to the other. It looks like the variable resets to its default value when FolderFullName ends and passes control back to the main task.

No problem if I just insert the three lines of text in the main task and forget about Running FolderFullName.atmn.
__________________
--Baffled in Brooklyn
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -7. The time now is 06:22 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 ©2007, Crawlability, Inc.
Copyright © 2003-2008 Tethys Solutions, LLC. All rights reserved