kmaxie Posted April 27 Share Posted April 27 (edited) Good morning. The following is a script that I've used in the past to read in values from an array to copy files to a specific network folder. The script is designed to maintain the folder hierarchy of the files that are to be copied. A regular and knowledgeable user of AutoIT helped me to create this script, and it worked perfectly when it was first run in production. I recently re-wrote parts of the script to accommodate a new source of files and an updated network location. I cannot, however, get the script to run. I am hopeful that someone could take a look at this script and provide feedback as to why it isn't working. Is a problem with the comments? Possibly a permissions issue? Thank you all for your time. expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.16.1 Author: XXXXX XXXXX Script Function: This script is intended to resend XXXXXXXXXX files to XXXXXXXXXX for ingestion. The files to be sent are to be retrieved from a .csv file. #ce ---------------------------------------------------------------------------- ; Begin Code #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> #include <Debug.au3> Global $aRetArray[1][2] $sFilePath = "X:\Auto IT\XXXXXXXXXX.csv" _FileReadToArray($sFilePath, $aRetArray, Default, ",") ;MsgBox(0,"Status","Here's one row" & $aRetArray[1162][1]) _DebugArrayDisplay($aRetArray, "XXXXXXXXXX XX Array") $start = 1 $max = $aRetArray[0][0] ;$start = 2 ;$max = 2 $good = 0 $bad = 0 $missing = 0 For $g = $start To $max $findx = FileExists($aRetArray[$g][0]) If $findx <> 1 Then $missing = $missing + 1 MsgBox(0, "missing", "row: " & $g & " " & $aRetArray[$g][0]) Else ; ready to copythrn If 0 > 0 Then $confirm = FileCopy($aRetArray[$g][0], $aRetArray[$g][1], 9) ; 9 is 1 overwrite and 8 create path ; MsgBox(0,"Status","confirm row: " & $g & " " & $confirm) If $confirm = 1 Then ; 1 mean success $good = $good + 1 Else $bad = $bad + 1 EndIf EndIf ; IMPOSS EndIf ; findx check Next MsgBox(0, "Status: total max = " & $max, "total good = " & $good & @CRLF & "total bad = " & $bad & @CRLF & "total missing: " & $missing) Exit FileCopy($aRetArray[1][2], "X:\xxxxxxxxxx\xxxxxxxx xxxxxx-xxxxxx xxx-xxxx-xxxxxxxxxxxx\XXXXXXXXXX", 8) Edited April 27 by Jos added codebox & Tidied source Link to comment Share on other sites More sharing options...
Developers Jos Posted April 27 Developers Share Posted April 27 Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 27 Developers Share Posted April 27 13 minutes ago, kmaxie said: I recently re-wrote parts of the script to accommodate a new source of files and an updated network location. I cannot, however, get the script to run. I am hopeful that someone could take a look at this script and provide feedback as to why it isn't working. Is a problem with the comments? Possibly a permissions issue? Care to share what isn't working and what you have changed, as else we will be stabbing in the dark? somdcomputerguy 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
kmaxie Posted April 28 Author Share Posted April 28 Good morning, My apologies for my delay in responding and my lack of clarity in my original post. I was tasked to copy files listed in a .csv to a different network-based folder for zipping and transport through (S)FTP. The files in the .csv are in several, different locations, and copying and pasting them by hand would have taken significant time. I created the .csv that is to be read into the FILECOPY function. The .csv contains the original location of the files and their intended destination. It is important that the copied files have a certain folder hierarchy for continuity purposes. The intended folder structure (hierarchy) is listed in the second column of the .csv. The original file locations are in the first column of the .csv. Link to comment Share on other sites More sharing options...
kmaxie Posted April 28 Author Share Posted April 28 The script, after I edited, stopped at popping up the array. It would not copy the files from their source locations to their destinations. Sorry for posting in the wrong location in this forum. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 28 Developers Share Posted April 28 Well your posted code will not do anything when a file exists. Is that what you want? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
kmaxie Posted April 28 Author Share Posted April 28 Thank you for responding, Jos. No, I would like the script to copy the existing file to a new location. What is preventing the script, in its current iteration, from doing this? Link to comment Share on other sites More sharing options...
Developers Jos Posted April 28 Developers Share Posted April 28 Well you added an if 0>0 then test which i assume you understand will never be true? So what about you properly review your own code and try to understand what you have coded first? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
kmaxie Posted April 28 Author Share Posted April 28 Okay. I am willing to do that. What is the approach to troubleshooting this? I should also note that I was not the principal architect of this code. Its original author has departed, and I may not have enough time to figure this out (as much as I'd like to do so). Is it possible that PowerShell may be more appropriate for the task? Link to comment Share on other sites More sharing options...
argumentum Posted April 29 Share Posted April 29 (edited) 2 hours ago, kmaxie said: Is it possible that PowerShell may be more appropriate for the task? You can write it in any language you choose but if you have no idea and have no time, your options are limited to hire some one who already knows how. I would, if were you, share a chunk of the csv file with some made up data, the original code and what you need changed. Am sure someone here will write it for you. Just ask. Edit: by made up data don't mean x\xxx\xxx-xxx !!! Edited April 29 by argumentum xxxx Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 29 Developers Share Posted April 29 9 hours ago, kmaxie said: What is the approach to troubleshooting this? Did you actually understand the comments I made about the "if" never being true, so hence never running that portion of code? So start explaining why it is there! SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
kmaxie Posted May 1 Author Share Posted May 1 Good evening. I hope all is well. I am hugely appreciative of all your feedback, Jos. I was able to solve my issue with PowerShell. I will be checking in periodically because my organization regularly uses AutoIt. Again, thank you for your assistance. K.. 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