Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
folder sync
#1
Hi there,
i'm somewhat new to python, i have mostly coded in java(eclipse) and autohotkey(AHK Studio)
so i could use some help figuring out how to sync directories once a change was detected which the following script is responsible for:
import sys
import time
import logging
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler

if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s - %(message)s',
                        datefmt='%Y-%m-%d %H:%M:%S')
    path = sys.argv[1] if len(sys.argv) > 1 else '.'
    event_handler = LoggingEventHandler()
    observer = Observer()
    observer.schedule(event_handler, path, recursive=True)
    observer.start()
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
link to the source of that code: https://pypi.python.org/pypi/watchdog

any help is greatly appreciated !

Cheers ;)

yawikflame
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 566 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 23,818 Nov-02-2023, 08:20 AM
Last Post: South_east
  asyncio calls within sync function ( Websocket on_open) orion67 0 1,423 Jan-16-2022, 11:00 AM
Last Post: orion67
  Compare filename with folder name and copy matching files into a particular folder shantanu97 2 4,509 Dec-18-2021, 09:32 PM
Last Post: Larz60+
  Move file from one folder to another folder with timestamp added end of file shantanu97 0 2,485 Mar-22-2021, 10:59 AM
Last Post: shantanu97
  Auto re-pair / re-sync Controller via Script? User3000 2 2,346 Nov-30-2020, 11:42 AM
Last Post: User3000
  Python Cut/Copy paste file from folder to another folder rdDrp 4 5,075 Aug-19-2020, 12:40 PM
Last Post: rdDrp
  Pycharm sync PTPeter 1 1,954 Apr-22-2020, 03:50 PM
Last Post: DeaD_EyE
  Delete directories in folder is not working after folder is updated asheru93 2 2,666 Feb-13-2019, 12:37 PM
Last Post: asheru93
  copy content of folder to existing folder shlomi27 0 2,644 Aug-11-2018, 01:44 PM
Last Post: shlomi27

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020