Intelligent Automation & Macro Software  

Go Back   Automation Anywhere, Inc. 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 08-18-2009, 01:10 PM
KenRyan KenRyan is offline
Member
 
Join Date: Jan 2009
Posts: 37
Default Problem With "Delete Files" task?

Can a kind soul have mercy on a still-learning AA User?

I can't seem to make a fairly basic task in AA work for me. I'm trying to delete certain files from a folder on my computer if the file name matches one in a list variable containing several file names.

I'm sure it's just something simple that I'm missing, but I've attached relevant files here.

To get to the most basic elements of this task, I created a test list variable with only one file name in it. Then I put a file with THAT name (ahead.ogg) into a folder on my computer. I can't even get my script to delete that one file.

Any guidance appreciated! I've spent about 10 hours trying everything I can to make this work, to no avail.

Thanks!

Ken
Attached Files
File Type: atmn Simple Delete Test.atmn (316 Bytes, 2 views)
File Type: txt deletetest.txt (20 Bytes, 2 views)
Reply With Quote
  #2 (permalink)  
Old 08-18-2009, 04:49 PM
forumsupport forumsupport is offline
Senior Member
 
Join Date: Apr 2007
Posts: 1,342
Default

Hello,

The variable name in text file and the one used in if condition are different hence the task is not working as expected. Attached is updated text file. Also, you can use 'Include' operator instead of 'Equal to' in If condition like this,

Start Loop " Each File in D:\PIGTones\aa Delete Test"
If $FileName$ Includes $DeleteTestAug09$ Then
Delete Files "D:PIGTones\aa Delete test\$FileName$.$Extension$"
End If
End Loop

Hope that helps.
Attached Files
File Type: txt deletetest[1].txt (25 Bytes, 2 views)
Reply With Quote
  #3 (permalink)  
Old 08-19-2009, 12:23 PM
KenRyan KenRyan is offline
Member
 
Join Date: Jan 2009
Posts: 37
Default

Thanks for the quick reply. I changed the text file to reflect the same variable name as in the If condition. I also adjusted the directory name spelling in the "Delete Files" instruction (had one letter lower-case). But that still did not do the trick. Here is what that test looked like:

Start Loop " Each File in D:\PIGTones\aa Delete Test"
If $FileName$ Equal To $DeleteTestAug09$ Then
Delete Files "D:PIGTones\aa Delete Test\$FileName$.$Extension$"
End If
End Loop

The text file has only this: DeleteTestAug09=ahead.ogg

I then tried it with the "Includes" instead of the "Equals," and still no joy.

Both tasks are attached.

Is there still something wrong that I'm just not seeing?

Thanks again!

Ken
Attached Files
File Type: atmn simple delete test 2.atmn (317 Bytes, 0 views)
File Type: atmn Simple Delete Test 3.atmn (317 Bytes, 0 views)
Reply With Quote
  #4 (permalink)  
Old 08-19-2009, 12:37 PM
KenRyan KenRyan is offline
Member
 
Join Date: Jan 2009
Posts: 37
Talking

Doh! I just made it work but I'm still not certain why it didn't work with the corrections you suggested.

In my text file, I put the filename and extension like so: "DeleteTestAug09=ahead.ogg." I removed the extension from the reference to the file in the text file to read "DeleteTestAug09=ahead" and voila!

BTW, it worked with both the "Equal to" and the "Includes" versions of the task.

The only thing I can think of is that the IF condition states "If $FileName" Equal To..." and not If $Filename$.$Extension$ Equal To..." But I couldn't figure out how to enter both variables (Filename and Extension) into the If condition edit screen. Is there a way to do that?

Either way, the immediate problem is solved!! Thanks for your help.

Ken
Reply With Quote
  #5 (permalink)  
Old 08-19-2009, 01:13 PM
forumsupport forumsupport is offline
Senior Member
 
Join Date: Apr 2007
Posts: 1,342
Default

Hello,

Yes, the system variable $Filename$ contains the file name only and not the extension. If you wish to check for both the file name and extension then you can try something like this,

Start Loop " Each File in D:\PIGTones\aa Delete Test"
If $Extension$ Equal To "ogg" Then
If $FileName$ Equal To $DeleteTestAug09$ Then
Delete Files "D:PIGTones\aa Delete test\$FileName$.$Extension$"
End If
End If
End Loop

Hope that helps.
Reply With Quote
  #6 (permalink)  
Old 08-19-2009, 02:56 PM
KenRyan KenRyan is offline
Member
 
Join Date: Jan 2009
Posts: 37
Default

Grr. Another problem (sorry!)

My goal is to delete 153 files from a set of 199 that I know will be in a directory. I thought I could create a list variable containing the 153 filenames I needed to delete. But I think I'm applying the If $Filename$ condition wrong. Here's what is happening in my tests as I build toward this: If my text file contains, say 5 of the filenames to be deleted, and the folder contains exactly those 5 or more, it works fine. However, if the first file in the folder does not match the first file in the text file, nothing gets deleted at all. There's a logic error here that I can't suss. Sorry to be dense. Am I missing something obvious...again?

Example: Using the task attached, and placing the files "500.ogg, 600.ogg, and 700.ogg into the test folder, nothing gets deleted using the text file that says only "DeleteTestAug09=600,700." However, if I remove "500.ogg" from the test folder (leaving 600.ogg and 700.ogg only), and run the task again, both files get deleted.

Hopefully I described this clearly.

Thanks!

Ken
Attached Files
File Type: atmn simple delete test 2.atmn (317 Bytes, 3 views)
Reply With Quote
  #7 (permalink)  
Old 08-19-2009, 04:41 PM
forumsupport forumsupport is offline
Senior Member
 
Join Date: Apr 2007
Posts: 1,342
Default

Hello,

You need to create list variable, DeleteTestAug09 and use Loop for list variable inside 'Loop for each file in a folder'. Text format of task would be something like this,

Start Loop " Each File in D:\PIGTones\aa Delete Test"
Start Loop " List Variable DeleteTestAug09"
If $FileName$ Includes $DeleteTestAug09$ Then
If File Exists("D:\PIGTones\aa Delete Test\$FileName$.$Extension$") Then
Delete Files "D:\PIGTones\aa Delete Test\$FileName$.$Extension$"
End If
End If
End Loop
End Loop

We have attached sample task for your reference. Please copy it under location, 'C:\...\My Documents\Automation Anywhere\Automation Anywhere\My Tasks' folder.

Note: Please ensure $DeleteTestAug09$ is List variable.
Attached Files
File Type: atmn simple delete test 2.atmn (501 Bytes, 2 views)
Reply With Quote
  #8 (permalink)  
Old 08-21-2009, 10:44 AM
KenRyan KenRyan is offline
Member
 
Join Date: Jan 2009
Posts: 37
Default

YEss! That worked. Whew! Thanks so much.

Ken
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 03:51 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 ©2007, Crawlability, Inc.
Copyright © 2003-2011 Automation Anywhere, Inc. All rights reserved