Delete a folder with a wildcard character

majx767

Profile photo of majx767

  • Joined: Jun 28, 2011
  • Posts: 3

  • Participant

Tue 28/06/2011 at 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:appdatacASM.FC1ACB96B7779CF44525BCCBAB5D3A50D96CBAC3.1

 

I’ve tried and this doesn’t work.

C:AppDatacASM.*

 

Any ideas?

#1

majx767

Profile photo of majx767

  • Joined: Jun 28, 2011
  • Posts: 3

  • Participant

Tue 28/06/2011 at 19:27

That was:

Delete Folder C:appdataCASM.*

#2

Samantha

Profile photo of Samantha

  • Joined: Apr 23, 2010
  • Posts: 2749

  • Key Master

Wed 29/06/2011 at 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

Attachments:
You must be logged in to view attached files.
#3

majx767

Profile photo of majx767

  • Joined: Jun 28, 2011
  • Posts: 3

  • Participant

Thu 30/06/2011 at 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:UsersguestAppDataRoamingcasm.*"
FSO.DeleteFolder(Folder)

 

 

#4

Samantha

Profile photo of Samantha

  • Joined: Apr 23, 2010
  • Posts: 2749

  • Key Master

Thu 30/06/2011 at 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

You must be logged in to reply to this topic.

Viewing 5 posts - 1 through 5 (of 5 total)