txj Posted March 12, 2009 Share Posted March 12, 2009 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. Link to comment Share on other sites More sharing options...
Authenticity Posted March 12, 2009 Share Posted March 12, 2009 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 =]. Link to comment Share on other sites More sharing options...
txj Posted March 16, 2009 Author Share Posted March 16, 2009 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now