Using wildcards in OperatingSystem library keyword Move File

151 views
Skip to first unread message

Sami Sallmen

unread,
Dec 16, 2013, 11:51:18 AM12/16/13
to robotframe...@googlegroups.com
It seems that it is not possible to use wildcards in "Move File" keyword in the source path, am I right?
I meant that if I would like to move all the files matching pattern path/file-*.txt to a directory, it is not possible using that keyword. Or, if I know that I will have only one file matching that pattern and I would like to rename that, it is not possible to do that either. Of course the part of the file name indicated with asterisk changes on every run of the tests.

What would you recommend me to use for those purposes?

--Sami

Tatu Aalto

unread,
Dec 16, 2013, 1:59:56 PM12/16/13
to sami.s...@gmail.com, robotframe...@googlegroups.com
Ugh

There is workaround, one can specify pattern for the List Files In
Directory keyword and then iterate the list on a for loop. Example like
this:
*** Settings ***
Library OperatingSystem

*** Test Cases ***
move files
move files in directory source destination *foo*

*** Keywords ***
move files in directory
[Arguments] ${source folder} ${destination folder} ${pattern}=*
@{files} List Files In Directory ${source folder} ${pattern}
:FOR ${item} IN @{files}
\ Move File ${source folder}${/}${item} ${destination
folder}${/}${item}

Although it would be nice to specify a pattern also for the Move/Copy
keywords. If you feel that it is important for you, write an enhancement
request. Also, if you have lot of file, lets say like in thousands, this
will take lot of time and it would be best to seek other solutions,
because for loop it not best suited for that kind of operations.

-Tatu
> --
> You received this message because you are subscribed to the Google
> Groups "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to robotframework-u...@googlegroups.com.
> To post to this group, send email to
> robotframe...@googlegroups.com.
> Visit this group at http://groups.google.com/group/robotframework-users.
> For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages