Search code examples
pythonwindowsfile-transfer

Is it possible to run a python script from within another python script?


I have two python scripts, one moves video files from my downloads folder to a folder in my videos folder, the second is carykh's jumpcutter program https://github.com/carykh/jumpcutter . cary's program takes parser arguments when you run it. I want my first program that moves files (which is running continuously and moves files as soon as it detects them) to execute cary's jumpcutter after it moves a file. is there a way to do this?

I currently have a batch file that runs cary's jumpcutter with all my predefined parser arguments, but i have to run it manually for each video and want it to automatically run for each video one after another.

I'll add some code to this post later this afternoon.

So, what the program should do is, detect that a video has been downloaded, move it to the folder in my videos folder, and run cary's jumpcutter on the video. What it is currently doing is detecting that a video has been downloaded, moving it to the correct folder and doing nothing after that.


Solution

  • You've got at least a couple of options:

    1. Use os.system() or subprocess.call()
    2. Open the file containing the script you want to run and pass it to eval()

    I would try first the first option since they allow passing parameters.