MCPcopy Index your code
hub / github.com/geekcomputers/Python / main

Function main

smart_file_organizer.py:96–125  ·  view source on GitHub ↗

Parse command-line arguments and execute the file organizer.

()

Source from the content-addressed store, hash-verified

94
95
96def main() -> None:
97 """Parse command-line arguments and execute the file organizer."""
98 parser = argparse.ArgumentParser(
99 description="Organize files in a directory into categorized subfolders."
100 )
101 parser.add_argument("--path", required=True, help="Directory path to organize.")
102 parser.add_argument(
103 "--interval",
104 type=int,
105 default=0,
106 help="Interval (in minutes) to repeat automatically (0 = run once).",
107 )
108 args = parser.parse_args()
109
110 if not os.path.exists(args.path):
111 print(f"Path not found: {args.path}")
112 return
113
114 print(f"Watching directory: {args.path}")
115 print("Organizer started. Press Ctrl+C to stop.\n")
116
117 try:
118 while True:
119 organize_files(args.path)
120 if args.interval == 0:
121 break
122 print(f"Waiting {args.interval} minutes before next run...\n")
123 time.sleep(args.interval * 60)
124 except KeyboardInterrupt:
125 print("\nOrganizer stopped by user.")
126
127
128if __name__ == "__main__":

Callers 1

Calls 1

organize_filesFunction · 0.85

Tested by

no test coverage detected