Ask a Question

How to use wildcards in aqfilesystem to move and rename a file


How to use wildcards in aqfilesystem to move and rename a file

I download files from a webpage. This filenames  are individual(and i do not know them before downlaoding)  like e.g.  "response_1655109976711.json" , "response_1657109876736.json" 


What i want to do:
i want to copy the created file to the project Path folder and later on compare it with an existing file.
The problem seems to be that I can not rename the file correctly because wildcards do not work.


If I use a hardcoded filename the copy and rename in the script is working.
But how to use placeholders?
Example for such a script with a hardcoded name (working):

function MoveAndRenameFileExample()
var OldPath = "C:\\Users\\testuser\\Downloads\\response_1655109976711.json";
var NewPathMove = Project.Path+"Example.json";
var RenameOnCollision = false
aqFileSystem.RenameFile(OldPath, NewPathMove, RenameOnCollision) ;

For wildcards I  tried with the following lines
var OldPath = "C:\\Users\\testuser\\Downloads\\*.json";
var OldPath = "C:\\Users\\testuser\\;response_?????????????.json

But  I always get an error (at renaming).

Alternatively it would also help me if sowmebody can tell me how I can get the complete path and filename (like C:\\Users\\testuser\\Downloads\\response_1655109976711.json) of the last downloaded file so that i can use it as e.g. last operating result and then moves/rename it?

i am now able to find the file using
but still have the problem how to move and rename it.

Champion Level 3

Use log.message right after you get OldPath and let's see what's actually in there

i am using log.message and i can see the name of the file (e.g. response_1655186284821.json) in the log.
But how can i use that information to rename/move the file or in a rename or move script or to use it with filecompare?

Champion Level 3

This looks like it would work for you. The result object would have only your one file in it and you could get the name from there.

Showing results for 
Search instead for 
Did you mean: