ProgrammingNoob Posted September 5, 2019 Share Posted September 5, 2019 Hello all, I'm very new to AutoIt and programming/Skripting, please be gentle to me. For the life of me I cannot find a way for any of my attempts to work, I'm sorry. I'm trying to do the following: When someone copies a file to "H:\TestCopyOut", it should be recognized that there is a new file and it should be copied to "L:\TestCopyIn" and create a log file in folder "H:\TestCopyOut\LOG" with Date, Time, file name and success/fail. I hope one of you really clever people out there can help me with this please. I thank you in advance. Link to comment Share on other sites More sharing options...
alienclone Posted September 5, 2019 Share Posted September 5, 2019 check out help files for .... https://www.autoitscript.com/autoit3/docs/keywords/While.htm https://www.autoitscript.com/autoit3/docs/functions/FileExists.htm https://www.autoitscript.com/autoit3/docs/functions/FileCopy.htm https://www.autoitscript.com/autoit3/docs/libfunctions/_FileWriteLog.htm If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
alienclone Posted September 5, 2019 Share Posted September 5, 2019 just a note on While...WEnd, it can be a little confusing at first. in this case we just need to use it to make the script loop over and over, the While checks if the expression is true, and if it is then it proceeds with the script encased in it. simplest way is to... While(1) WEnd "1" will always be true so the script inside the While...WEnd will repeat over and over. you will need to leave the script running at all times to watch for the file to exist. If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
ProgrammingNoob Posted September 5, 2019 Author Share Posted September 5, 2019 16 minutes ago, alienclone said: check out help files for .... https://www.autoitscript.com/autoit3/docs/keywords/While.htm https://www.autoitscript.com/autoit3/docs/functions/FileExists.htm https://www.autoitscript.com/autoit3/docs/functions/FileCopy.htm https://www.autoitscript.com/autoit3/docs/libfunctions/_FileWriteLog.htm Hi, thanks for the fast reply. I've found all of those already and looked at it but I have no idea how to use all of those, and I know even less how to use those together. Sorry, like I said, I am completely new to this. Link to comment Share on other sites More sharing options...
alienclone Posted September 5, 2019 Share Posted September 5, 2019 we were all noobs at one point, this is the place to learn. im on my way to bed at the moment, but you read those help files i linked to, and search using the link in my signature and come up with something that looks like a script and post it here then others will follow with help debugging YOUR SCRIPT. or you can wait for other members here who like doing other people's homework for them, you may get lucky and not have to learn a thing. ProgrammingNoob 1 If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
alienclone Posted September 5, 2019 Share Posted September 5, 2019 (edited) i forgot one.... https://www.autoitscript.com/autoit3/docs/keywords/Do.htm and... https://www.autoitscript.com/autoit3/docs/functions/Sleep.htm Edited September 5, 2019 by alienclone If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
alienclone Posted September 5, 2019 Share Posted September 5, 2019 so if you use the functions listed you should... while do sleep until fileexists then filecopy filewritelog wend If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
Earthshine Posted September 5, 2019 Share Posted September 5, 2019 (edited) check out this thread, then add some logging, search forum for logging Edited September 5, 2019 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
ProgrammingNoob Posted September 6, 2019 Author Share Posted September 6, 2019 I've managed this so far, it copies the files from "H:\" to "L:\" when I execute the program, but I cannot figure out who or what to do with the rest of the stuff 😞 Local $hSearch = FileFindFirstFile("H:\TestCopyOut\*.*") While 1 $sFileName = FileFindNextFile($hSearch) If @error Then ExitLoop If not FileExists("L:\TestCopyIn\" & $sFileName) Then FileCopy("H:\TestCopyOut\" & $sFileName, "C:\TestCopyIn\") WEnd FileClose($hSearch) Link to comment Share on other sites More sharing options...
ProgrammingNoob Posted September 6, 2019 Author Share Posted September 6, 2019 22 hours ago, alienclone said: we were all noobs at one point, this is the place to learn. im on my way to bed at the moment, but you read those help files i linked to, and search using the link in my signature and come up with something that looks like a script and post it here then others will follow with help debugging YOUR SCRIPT. or you can wait for other members here who like doing other people's homework for them, you may get lucky and not have to learn a thing. I've managed this so far, it copies the files from "H:\" to "L:\" when I execute the program, but I cannot figure out who or what to do with the rest of the stuff 😞 Local $hSearch = FileFindFirstFile("H:\TestCopyOut\*.*") While 1 $sFileName = FileFindNextFile($hSearch) If @error Then ExitLoop If not FileExists("L:\TestCopyIn\" & $sFileName) Then FileCopy("H:\TestCopyOut\" & $sFileName, "C:\TestCopyIn\") WEnd FileClose($hSearch) Link to comment Share on other sites More sharing options...
alienclone Posted September 6, 2019 Share Posted September 6, 2019 for your log you just need to expand your IF a little bit. https://www.autoitscript.com/autoit3/docs/libfunctions/_Now.htm if not fileexists then filecopy filewritelog $filename date endif If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
ProgrammingNoob Posted September 10, 2019 Author Share Posted September 10, 2019 Thanks to all for trying to help. I've just realized that I'm more useless than what I thought, I have no idea how to do this, I still only managed to get it to copy, I don't get anything else to work. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted September 10, 2019 Share Posted September 10, 2019 @ProgrammingNoob Don't even say that! What problem are you facing now? Post your script so we can help you Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
ProgrammingNoob Posted September 10, 2019 Author Share Posted September 10, 2019 4 hours ago, FrancescoDiMuro said: @ProgrammingNoob Don't even say that! What problem are you facing now? Post your script so we can help you The script is still the same, I cannot figure out how to get it to chech the folder for when a new file come into the folder and I don't get the log file to work This is what I have so far Local $hSearch = FileFindFirstFile("H:\TestCopyOut\*.*")While 1 $sFileName = FileFindNextFile($hSearch) If @error Then ExitLoop If not FileExists("L:\TestCopyIn\" & $sFileName) Then FileCopy("H:\TestCopyOut\" & $sFileName, "C:\TestCopyIn\")WEndFileClose($hSearch) 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