Jump to content

is this possible with auto it


Recommended Posts

for the logrecord.txt

that sounds like what i would want except for the closing it, i would assume its possible to leave it open after the time it was written, perhaps saving the txt file as the current date.

my current code as it stands at this moment, this is not the final as i know how to add and change what is being copied and to where as this will change as more pc's get put online on the home network

DirCopy("D:\images", "C:\foo\images", 0)
DirCopy("D:\thumbnails", "C:\foo\thumbnails", 0)
FileCopy("D:\test.mvc", "C:\foo\", 1)
MsgBox(1,"transfer", "completed", 0)
FileCopy("D:\test.mvc", "\\stargate\d", 1)

That's good, does this script work for your purpose?

For several thousand files, it'll take a long time to process but it should work.

Link to comment
Share on other sites

DirCopy("D:\images", "C:\foo\images", 0)
DirCopy("D:\thumbnails", "C:\foo\thumbnails", 0)
FileCopy("D:\test.mvc", "C:\foo\", 1)
FileCopy("D:\test.mvc", "\\stargate\d", 1)

that actually is the current code, there is no message box because that pauses the copying, wonder how that got back in there, must have forgotten to save something.

as for the copying yes it works just fine does not take long to copy on the gigabyte lan setup.

while there may be a lot of files the total size of everything is about 600-800megs.

so the log file i am not sure how to do this. i didn't see anything on it in the help file on how to set it up.

especially on how to open it up to begin with, i know there is a code to open a notepad file so i'd assume you start with that, perhaps before the copying and such so its open.

then when each copying is completed it appends the text file with how many files was copied over and such,

then moves onto the next copying setup and then appends at the end of it and so one.

please note that the code listed is still the sample and is going to change in terms of the copying locations

for example copying to the c:\foo in the final will not be there and the networked location witch with this script currency is only getting the one file will have both folders and file

as well as two more networked pc's eventually

not sure when i'll have a bit if free time to pursue this more as

i have a template i am trying to figure out and edit (css, xls files) and like autoit i knew nothing on it.

i have another more complex autoit script (another post i did on her) and i think i am making headway with that that i need to do some testing with and such.

Link to comment
Share on other sites

To be honest, FileCopy only returns a 1 or 0 whether it succeeded or failed. You won't have much to log.

You'd have to enumerate each file in the folder and subfolders, then run a loop to "FileCopy" each individual file and write a custom log file with each file copied and a little message like "succeeded". That's pretty uneffective.

Here's a good way to copy files and keep a log:

Type this in a CMD window:

Copy D:\images C:\foo\images > c:\log.txt

Hey, instant log :mellow:

Just make an autoit script using "Run" commands to run DOS copy command and you'll have what you want.

Link to comment
Share on other sites

i have one script on this that will close the program so the file can be over written.

can't figure out how to create a script that will see if the program is open and if it is have it save the file and exit, it would be nice but its only a just in case as i usually close the program before heading to bed or work but even if i don't i've at least saved the file.

Show me your code for what you have currently on this. I will help point you in the right direction.

Here is a sample of using ProcessExists to see if a Outlook is running and if not, then running it. Also, a simple closing function for Outlook.

;===============================================================================================================================
;   Outlook Functions

Func _OutlookOpen()
    Sleep(1000)
    If ProcessExists("Outlook.exe") Then
        WinActivate("[Class:rctrl_renwnd32]")
    Else
    Run ("C:\Program Files\Microsoft Office\Office10\Outlook.exe")
    Sleep(1000)
    EndIf
EndFunc


Func _OutlookClose()
    Sleep(1000)
    If ProcessExists("Outlook.exe") Then
        WinActivate("[Class:rctrl_renwnd32]")
        Sleep(1500)
        Send("!{F4}")
    EndIf
EndFunc

;===============================================================================================================================
Link to comment
Share on other sites

here is the one script that terminates the program

its very simple it don't ask for anything it just forces the program to temrinate i was not interested in saving the file or anything on it, since those pc's files are being overwritten.

its the main pc that i want to get it to save the file and terminate, no need to name it as its already saved with the right name prior so saving it just saves the most recent copy with all the updates

ProcessClose("MovieCollector.exe")
$PID = ProcessExists("notepad.exe") ; Will return the PID or 0 if the process isn't found.
If $PID Then ProcessClose($PID)
Link to comment
Share on other sites

To be honest, FileCopy only returns a 1 or 0 whether it succeeded or failed. You won't have much to log.

You'd have to enumerate each file in the folder and subfolders, then run a loop to "FileCopy" each individual file and write a custom log file with each file copied and a little message like "succeeded". That's pretty uneffective.

Here's a good way to copy files and keep a log:

Type this in a CMD window:

Copy D:\images C:\foo\images > c:\log.txt

Hey, instant log :mellow:

Just make an autoit script using "Run" commands to run DOS copy command and you'll have what you want.

so powercat your suggesting something along the lines of

#include <Process.au3>
$rc = _RunDos("Copy D:\images C:\foo\images > c:\log.txt")
$rc = _RunDos("Copy D:\thumbnails", "C:\foo\thumbnails", 0 > c:\log.txt")
$rc = _RunDos("Copy D:\test.mvc", "C:\foo\", 1 > c:\log.txt")
$rc = _RunDos("Copy D:\test.mvc", "\\stargate\d", 1 > c:\log.txt")

and to make sure i understand correctly for the filecopy and dircopy there is no way to really create a txt or log file easily (since in total there is about 13k in files) but this dos script/way would do it?

Link to comment
Share on other sites

DOS(general) note:

[>] will overwrite the target file with the new data.

[>>] will append the new data to the target file.

Windows(DOS) additional:

[1>] or [1>>] is STDOUT stream (same as [>]

[2>] or [2>>] is STDERR stream

Example:

_RunDos('Copy D:\images "C:\foo bar\images" 1> c:\log.txt 2>> c:\err.txt')

See http://www.dostips.com/ for more DOS info.

---

:)

Giving squirrels flying lessons. :mellow:

Posted Image :)

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

You also might also want to have a look at _FileWriteLog() in the help. It might be preferable to a msgbox that dies if your computer shuts down, etc.

#include <file.au3>
_FileWriteLog("C:\Logs\MyLogFile.txt", "Copy completed with no errors")

It's cumulative, and prefaces each entry with the date and time.

2011-08-09 13:00:07 : Copy completed with no errors

2011-08-09 13:00:12 : Copy completed with no errors

2011-08-09 13:00:58 : Copy completed with no errors

2011-08-09 13:06:45 : Error - destination not found.

Link to comment
Share on other sites

ok

i don't have time to mess with anything today but if i understand this right

i don't have to have any code to create the txt file as that is already done automatically in the rundos command/line

but just to question why is there two txt listed in the example?

thanks

Link to comment
Share on other sites

hello everyone,

i've not had a change to proceed any further , hopefully i'll get some free time tomorrow to do something.

looking at that outlook example i not sure where in that script its saving the file, well i guess outlook don't really need a file saved. but not sure how to get a file to save, i'm thinking and perhaps i am wrong, after the program is determined to be open, i should use mouse click to click on the file, and then another mouse click to click on save and so on until its saved, then have it close,

as for the text file has it been determined that its too complex, slow, etc to have it list the number of files updated?

again i hope to get around to playing with them tomorrow.

Link to comment
Share on other sites

but just to question why is there two txt listed in the example?

If that is in relation to my example. Because there are two IO-data-streams. (Don't mean you need to use them both. Example!)

as for the text file has it been determined that its too complex, slow, etc to have it list the number of files updated?

Kinda unclear to what exactly your referring to. Everything has its Up & Down sides. I would focus on getting the job done first before targeting speed.

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

well while the script is not written yet, only the test script

it does what it needs too, in terms of copying the two folders and single file.

i'll be looking at velvet elvis to add the log file. i hope to get around to this later tonight

Link to comment
Share on other sites

You also might also want to have a look at _FileWriteLog() in the help. It might be preferable to a msgbox that dies if your computer shuts down, etc.

#include <file.au3>
_FileWriteLog("C:\Logs\MyLogFile.txt", "Copy completed with no errors")

It's cumulative, and prefaces each entry with the date and time.

2011-08-09 13:00:07 : Copy completed with no errors

2011-08-09 13:00:12 : Copy completed with no errors

2011-08-09 13:00:58 : Copy completed with no errors

2011-08-09 13:06:45 : Error - destination not found.

is the first line required for this #include <file.au3> and if so i assume i need to have the script name in for hte file.au3

Link to comment
Share on other sites

is the first line required for this #include <file.au3>

Yes. To use the function _FileWriteLog() that first line, "#include <file.au3>", is needed.

and if so i assume i need to have the script name in for hte file.au3

Yep. ... Odd thing it that you already have the name ... and the file to. If you did make AutoIt install the 'User Defined Functions' part to. :mellow:

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

A User defined function it a function you, as user, created. And there used in the same way as internal available function.

Example

Func MyUserFunction([optional parms/function input])
  local $SomeVariable = 'Somedata'
  ;; some code
  return $SomeVariable ;; function output.
EndFunc

See manual for additional info. (anything particular you don't understand about functions after that, ask again.)

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...