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 01-20-2009, 06:19 PM
KenRyan KenRyan is offline
Member
 
Join Date: Jan 2009
Posts: 37
Default Deleting Select Files In a Folder of Many?

How can I delete a s list of specific files from a folder? From a folder containing 116 wave files, I have to delete all but 47 of them. The files all have numbers in them, ex. "Voice_013, Voice_014, etc." I only need to keep, say, "Voice_002," "Voice_003," "Voice_047," "Voice_113," etc. (a total of 47 files).

Is there a way to loop through the list of 116, deleting the ones that don't match the list, without having to do 47 separate "if/then" commands? I'm very new at this, and have figured out how to do the really common operations, but this one has me stumped.

Thanks.

Ken
Reply With Quote
  #2 (permalink)  
Old 01-20-2009, 11:00 PM
forumsupport forumsupport is offline
Senior Member
 
Join Date: Apr 2007
Posts: 1,342
Default

Hello,

You can create a list variable that would read values from a text file. List all the file names that you do not wish to delete in that text file. Now, you need to insert nested loop. First insert an outer loop, Loop for each file in a folder. Inside this loop, loop for the list variable, can compare the file names and the delete the file that is not in the list.

We have attached a sample task for your reference. To run this task, please follow below mentioned steps carefully,

. Please copy .atmn file under location, 'C:\...\My Documents\Automation Anywhere\Automation Anywhere\My Tasks' folder.
. Copy all .wav files under C:\. It would automatically create and store all the files in Temp folder.
. Copy .txt file under C:\.

Before running this task, please create variable, filelist through Variable Manager. To create a variable that read from text file, please follow below mentioned steps:

1. Go to Tools->Variable Manager in Automation Anywhere.
2. Click on 'Add New Variable'.
3. In 'Name' field, enter variable name i.e. filelist.
3. From Type dropdown select 'List'.
4. Select 'Read from text file' radio button or option.
5. In 'Value' field, specify the path of text file i.e c:\Test.txt.
6. Press 'Save' button.
7. Press 'Ok' button.

Run the task. It would delete all other files from temp folder that are not listed in test.txt.

Hope that helps.
Attached Files
File Type: zip DeleteSelectedFiles.zip (1.5 KB, 4 views)
Reply With Quote
  #3 (permalink)  
Old 01-21-2009, 11:05 AM
KenRyan KenRyan is offline
Member
 
Join Date: Jan 2009
Posts: 37
Default

It created a very similar task to what you showed, because I realized I had forgotten to mention that though the "*_013" (the underscore and number) part of these files will be the same every time, the "voice" part (originally I said files called "voice_013") will be different every time. So the txt file for my filelist variable only contains the numbers I want to keep (013, 035, 036, 037, etc.). Then I "thought" I was check each file name to see if it "contained" one of the "keeper" numbers with: "If $FileName" Does Not Include $filelist$ Then"

Not sure if that was right, because my Then task was: delete files "$CurrentDirectory$\$FileName$.$Extension$" does not result in any deleted files.

I attached my file. Is it possible to see what did wrong?

Thanks.

Ken
Attached Files
File Type: atmn DeleteSpecificFiles.atmn (649 Bytes, 0 views)
Reply With Quote
  #4 (permalink)  
Old 01-21-2009, 11:26 AM
KenRyan KenRyan is offline
Member
 
Join Date: Jan 2009
Posts: 37
Default

Here is a second attempt, since in the first one I forgot to go to the foler and loop through each file. But it still doesn't delete any files. Not sure what I'm doing wrong, but I still think it's how I'm doing the list. It only contains a portion of each file (the number part) that I want to keep. So I thought I had to compare each fileName with the list, and then delete that file if it didn't contain any of the numbers in the list. I'm gonna try again with some other ideas.

Ken
Attached Files
File Type: atmn deletespecificFiles2.atmn (730 Bytes, 2 views)
Reply With Quote
  #5 (permalink)  
Old 01-21-2009, 09:29 PM
forumsupport forumsupport is offline
Senior Member
 
Join Date: Apr 2007
Posts: 1,342
Default

Hello Ken,

We have amended your task and it works at our end. Please copy attached task under location, 'C:\...\My Documents\Automation Anywhere\Automation Anywhere\My Tasks' folder and run it.

Please let us know how it goes.
Attached Files
File Type: atmn deletespecificFiles2.atmn (1,003 Bytes, 5 views)
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 09:50 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