pankajbokdia Posted April 19, 2016 Share Posted April 19, 2016 Hello guys, I am very new to AutoIt and I am working on a small project. I want to be able to read data from a CSV line, search for that term in a folder and then copy paste that file to another folder. Can you please give me a few pointers that could help me move in the right direction? Any help would be greatly appreciated. Thanks in advance! Link to comment Share on other sites More sharing options...
AutoBert Posted April 19, 2016 Share Posted April 19, 2016 FileCopy($FoundDir,$NewDir), when showing CSV i can give better answer. Link to comment Share on other sites More sharing options...
pankajbokdia Posted April 19, 2016 Author Share Posted April 19, 2016 Thank you so much for the reply. Here is an example of the CSV file that I want to use. So just one function is enough? Sorry I am very new to this. Regards filename.csv Link to comment Share on other sites More sharing options...
Nunos Posted April 19, 2016 Share Posted April 19, 2016 If you know the filename then you could start with an If Then statement against the FIleExist function and the FileCopy functions. Example below. #include <MsgBoxConstants.au3> Local $iFileExists = "C:\Myfolder\Myfilename.csv" Local $iFileDest = "C:\NewFolder\Myfilename.csv" If $iFileExists Then FileCopy( $iFileDest ) Else MsgBox($MB_SYSTEMMODAL, "", "The file doesn't exist." & @CRLF & "FileExist returned: " & $iFileExists) EndIf Links to Documentation for both. https://www.autoitscript.com/autoit3/docs/functions/FileExists.htm https://www.autoitscript.com/autoit3/docs/functions/FileCopy.htm Link to comment Share on other sites More sharing options...
pankajbokdia Posted April 19, 2016 Author Share Posted April 19, 2016 Thank you for your reply. I will try and build the code from here Link to comment Share on other sites More sharing options...
AutoBert Posted April 19, 2016 Share Posted April 19, 2016 (edited) 1 hour ago, pankajbokdia said: So just one function is enough? No, read file in a array using _FileReadToArray, Loop through Array, in each step use FileCopy. This copies your files listed in CSV: #include <File> #include <Array> Global $aFiles Global $sSourceDir='c:\MySourceDir\' Global $sDesDir='c:\NewDestination\' Global $myCSV='PathToCSV_File' _FileReadToArray($myCSV,$aFiles,$FRTA_COUNT) _ArrayDisplay($aFiles) ;can be deleted only for check the array For $x = 0 to $aFiles[0] FileCopy($sSourceDir&$aFiles[$x],$sSourceDir&$aFiles[$x] Next Note: you have to correct the vars for your needs Edit: please have a look in help about used functions! @Nunos: FileCopy needs 2 params, have a look in your 2. link. Edited April 19, 2016 by AutoBert Link to comment Share on other sites More sharing options...
Nunos Posted April 21, 2016 Share Posted April 21, 2016 indeed 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