Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
DirectoryWatcher - Mirror structure to another disk.
DirectoryWatcher - Mirror structure to another disk.
I use EventGhost to automate my HTPC currently and everything works great. I have EventGhost watching for new files in a directory, then it launches therenamer, renaming my files and moving them to another location. Once this file hits the new location (d:\tv shows\show\season\file) I would like EventGhost to launch an event that copy's that file and the structure to another disk, so that i end up with a mirror of the data (f:\tv shows\show\season\file). I know NOTHING about python. Is this even possible to do? I was trying to play around with it using what i read from the other DirectoryWatcher post that deals with just copying a file to a new location but ive had no luck with my im trying to accomplish.
Thanks!
Thanks!
Re: DirectoryWatcher - Mirror structure to another disk.
Well, the easiest way is to use the standard windows tools for the job. Look up the syntax for xcopy.
Re: DirectoryWatcher - Mirror structure to another disk.
How do I use that in conjuction with EventGhost though? Are you talking about triggering a start application event, that will launch a batch file? If I have event ghost set to use DirectoryWatcher.Update and it sees that ive added a new folder 'test' is it possible to then put that string into the batch file to use xcopy? When you were suggesting xcopy did you have the /T switch in mind? Using that would only create the stucture but not copy the files.
Sorry for all the questions and if im not understanding what you were suggesting.
Thanks!
Sorry for all the questions and if im not understanding what you were suggesting.
Thanks!
Re: DirectoryWatcher - Mirror structure to another disk.
Yep, you got it. For syncing a whole tree at one go you should probably use robocopy though. But since it sounds relatively simple you could just use xcopy/copy/cp to copy the one file or folder.
Re: DirectoryWatcher - Mirror structure to another disk.
Hmmm... The tree is already synced. My issue is more when a new episode comes out therenamer knows to put the episode in the c:\tv shows\<show>\<season>\ folder. After this is done i would like to copy that file to another drive with the same path, d:\tv shows\<show>\<season>\. Is this not possible? I would prefer to not use a batch file that says copy all of c:\tv shows\ to d:\tv shows\. Seems like alot of overhead when im only wanting to copy one file.
Re: DirectoryWatcher - Mirror structure to another disk.
You should be able to do this in a python script. You can trigger the script from the event, then have the script grab the file name/location from the event payload.
Once you have the file as a string in the script, you should be able to use the path functions in the python os.path module (splitdrive for instance, and join) combined with the shutil module for copying.
Good luck,
Brett
Once you have the file as a string in the script, you should be able to use the path functions in the python os.path module (splitdrive for instance, and join) combined with the shutil module for copying.
Good luck,
Brett
Re: DirectoryWatcher - Mirror structure to another disk.
Would it be possible for you to show me an example of how i would do this? I dont know python but can surely manipulate a sample.
stottle wrote:You should be able to do this in a python script. You can trigger the script from the event, then have the script grab the file name/location from the event payload.
Once you have the file as a string in the script, you should be able to use the path functions in the python os.path module (splitdrive for instance, and join) combined with the shutil module for copying.
Good luck,
Brett
Re: DirectoryWatcher - Mirror structure to another disk.
Well, sure, you could do it with python script.. but that will have some problems of it's own -- for example; while your python script is copying large files your EG will stall processing of other events.. To avoid that you will have to run it in another thread which will make the script more complicated. Then when errors occur, what will you (or the script) do?
It will be easier to just use the existing tools like robocopy etc.. Make a macro that will launch robocopy for the target folder only and not the entire root dir to speed it up.
It will be easier to just use the existing tools like robocopy etc.. Make a macro that will launch robocopy for the target folder only and not the entire root dir to speed it up.
Re: DirectoryWatcher - Mirror structure to another disk.
I dont have EG doing much. My setup only has three macros. Two use the DirectoryWatcher.Create event that launches an action(Initiates EMM which scrapes a new movie), then updates XBMC video Library. This is triggered by a manual move that I do myself. Then my only other macro uses DirectoryWatcher.Updated event then starts an action to use therenamer to rename a tv show and move it. My setup isnt very complex. I dont think I would notice this stall your talking about. However I dont know that much about EG or scripting so I could be wrong. What do you consider large files? The biggest file it might copy is 1.5GB.
I still think using xcopy would be alot more overhead than what stottle was suggesting. Am I misunderstanding something?
I still think using xcopy would be alot more overhead than what stottle was suggesting. Am I misunderstanding something?
jinxdone wrote:Well, sure, you can do it with python. And while your python script is copying large files your EG will stall processing of other events while it's copying.. To avoid that you will have to run it in another thread which will make it more complicated. Then when errors occur, what will you (or the script) do?
Trust me, it will be easier to just use the existing tools like xcopy, robocopy or rsync etc..
Re: DirectoryWatcher - Mirror structure to another disk.
Well, running "robocopy c:\source d:\target" is not that hard. It's an app made in C/C++ of 125kb in size, so not much overhead. It only copies new or changed files by default so it does exactly what you want to do -- mirrors files.
You can go ahead and re-invent the same thing in a python script if you wish though..
You can go ahead and re-invent the same thing in a python script if you wish though..
Re: DirectoryWatcher - Mirror structure to another disk.
Sorry Jinx I was not familiar with how robocopy worked. I assumed it would try to copy everything every time it was ran, not just the new/changed files. I will take a look at this option. Thank you.
jinxdone wrote:Well, running "robocopy c:\source d:\target" is not that hard. It's an app made in C/C++ of 125kb in size, so not much overhead. It only copies new or changed files by default so it does exactly what you want to do -- mirrors files.
You can go ahead and re-invent the same thing in a python script if you wish though..