Sign in to follow this  
Followers 0
txj

how to get destination file name before runing FileCopy( )

3 posts in this topic

Hi ! everybody.

when source/destination file name has wildcard( * and/or ?), how to write source code to get destination file name before running FileCopy( ).

for example:

FileCopy( "test*.*", "file*.*" )

FileCopy( "test?.*", "file*.*" )

FileCopy( "test*.?", "file*.?" )

FileCopy( "test?.?", "file?.?" )

I want to write a function to carry out transaction/rollup file copy.

Share this post


Link to post
Share on other sites



Use _FileListToArray and parse each element using the string functions. If you hold array of filenames like:

Dim $aFilenames[2] = ['test', 'autoit']

and then searches it you can do this for example:

Dim $aFiles = _FileListToArray(@ScriptDir, $aFilenames[0] & '*.*', 1)

For $i = 1 To $aFiles[0]
       FileCopy( $aFiles[$i], StringRegExpReplace($aFiles[$i], ($aFilenames[0]), 'file', 1))
Next

It's not suppose to take multiple loop like that if you write it as a function or write something much simpler, it's a bad example I know =].

Share this post


Link to post
Share on other sites

Use _FileListToArray and parse each element using the string functions. If you hold array of filenames like:

Dim $aFilenames[2] = ['test', 'autoit']

and then searches it you can do this for example:

Dim $aFiles = _FileListToArray(@ScriptDir, $aFilenames[0] & '*.*', 1)

For $i = 1 To $aFiles[0]
       FileCopy( $aFiles[$i], StringRegExpReplace($aFiles[$i], ($aFilenames[0]), 'file', 1))
Next

It's not suppose to take multiple loop like that if you write it as a function or write something much simpler, it's a bad example I know =].

Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0