Delete a folder with a wildcard character

majx767

  • Joined: Jun 28, 2011
  • Posts: 3

Tue 6/28/2011 - 19:26

I have an application that creates a unique folder name each time an iteration occurs and needs to be deleted after a job has completed.

I've tried using wildcard characters to delete it but nothing has worked. The only commonality with the folder name is the beginning four characters are always the same.

c:\appdata\cASM.FC1ACB96B7779CF44525BCCBAB5D3A50D96CBAC3.1

 

I've tried and this doesn't work.

C:\AppData\cASM.*

 

Any ideas?

#1

majx767

  • Joined: Jun 28, 2011
  • Posts: 3

Tue 6/28/2011 - 19:27

That was:

Delete Folder C:\appdata\CASM.*

#2

Samantha

  • Joined: Apr 23, 2010
  • Posts: 2734

Wed 6/29/2011 - 11:07

Welcome to our Forum! The application that created this folder, is probably locking this folder, and therefore you cannot delete it. Try terminating the application prior to deleting the folder. To get the folder name, all you will need to do is use the "Get Subfolders in Folder" action, and then, within "For Each" a loop, check if the %CurrentFolder.Name% starts with cASM, if so, then Exit the Loop, and delete the %CurrentFolder% I'm attaching a sample job to help you understand the jobflow. :) Samantha

sample delete random folder.waj

#3

majx767

  • Joined: Jun 28, 2011
  • Posts: 3

Thu 6/30/2011 - 15:28

The information was really helpful and will be implemented. I also created a vbs script that I called from WinAutomation that was a little easier. Here's the code if anyone would find this useful.

 

DeleteFolder.vbs

Dim FSO, Folder
set FSO=CreateObject("Scripting.FileSystemObject")
Folder="C:\Users\guest\AppData\Roaming\casm.*"
FSO.DeleteFolder(Folder)

 

 

#4

Samantha

  • Joined: Apr 23, 2010
  • Posts: 2734

Thu 6/30/2011 - 15:42

Cool! Thanks for sharing! Btw... In WinAutomation v.4 you'll also be able to run vb scripts from within WinAutomation! :) Samantha

#5
Not a member yet? Register

Copyright 2014 - Softomotive Ltd