I have a script that takes the a number as command-line argument and moves files with this number into the folder with the respective number.
Example
For example, I have 20 folders named Episode 1
through Episode 20
.
I also have a total of 120 files, 5 files per folder file1-ep 1
, file2-ep1
would move into folder Episode 1
, and so on, all the way to file1-ep20
, file2-ep20
which would move into folder episode 20
, etc.
Code
I already have the script to move the files.
It just requires me following on command line: move.py 1
or move.py 2
, etc.
My current script:
import os
import sys
import shutil
path = "/Users/Macbook/Final Cut Pro/"
destination_path = f"/Users/Macbook/Final Cut Pro/episode {sys.argv[1]}/"
for (root, dirs, file) in os.walk(path):
for f in file:
f = f.lower()
if check_file(sys.argv[1])in f:
source = path + f
destination = destination_path + f
print(f)
# shutil.move(source, destination)
Basically, I want the program to loop automatically instead of asking for user input. So that I would just need to supply the start and stop numbers.
What I tried
I've tried putting the nested for
loops into another for
loop.
for i in range (1,21)
for loop
for loop
How can I make a loop so that it moves all the respective files into the folders without any user input?