How can I use an asterisk in the source for a file? Can I escape it somehow?
I could use a fileset to find *.zip, but I don’t really want to since I know it’s only going to find a single file. I could eliminate that step.
Attachment unavailable
Hi Katie,
You can use wildcards like * in the source directory. I don’t quite know what you mean by escaping the wildcard. If you wish to copy only one file then the simplest method to do this is to store the name of that file in a variable and reference it directly. If there is only one zip file in the directory, and its name may change then using an * seems like a good choice.
Lastly if you want some extra validation that only one file was copied. The AfterAction script on the copy files action allows you to query the number of copied files and set the result of the action. You can even write out a helpful failure message if you wish. E.g.
function AfterAction(Action, ActionResult, Continue)// This part is already defined for you.
if (Action.FilesAffected != 1) {
Action.SendLogMessage('Expected only one file to be copied!', stError)
ActionResult = false
}
Oh you’re right, Copy Files action does work with an asterisk in the file path. It just worked for me now.
Here are two other places I was not able to get an asterisk to work, does it make sense that it wouldn’t work here? In both of these cases, I know that here is only a single file that the action will find, I just want to use the asterisk because I don’t know what the name will be. My solution around this is to use the Find Files action to store the name in a variable, and the use the variable in each of these actions.
Hi Katie,
Using the find files action to locate the file using a file mask is your best bet. Both the two actions you have listed operate on a single file and therefore don’t take a file mask to locate files they will be working on.