Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Indentation and Syntax Errors in File Organizing Script in Python

I’ve been working on a file organizing script from a tutorial: https://www.youtube.com/watch?v=MRuq3SRXses&t=22s

However, I’m new to python, so much of its nuance is hidden to me.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have two indentation errors, as well as two syntax errors, however after looking at several questions on here, I still can’t seem to fix it.
I’m confident I did not mix spaces and tabs, and the person from the tutorial I used seem to use his version of the script perfectly fine.

As for the syntax errors, I do not know what the issue could be.

Here is a copy of my code:

import os
import shutil

origin_dir = r'D:\TTITF\Game Files and Animations\Animations\Bridges\Walk ~ Alvie - V_2 R RAW'
target_dir = r'D:\TTITF\Game Files and Animations\Animations\Bridges\Walk ~ Alvie - V_2 R TRIMMED'



for f in os.listdir(origin_dir):
    filename, file_ext = os.path.splitext(f)

    try:
        if not file_ext:
            pass

        elif int(filename) in range(0, 60):
            shutil.move(
                os.path.join(origin_dir, f'{filename}{file_ext}')
                os.path.join(target_dir, 'V_O to V_4', f'{filename}{file_ext}'))


    except (FileNotFoundError, PermissionError):
        pass

>Solution :

You need to run the python code on IDE such as VS code,Jupyter notebook, Pycharm ( which is mentioned in tutorial that you are watching). Most developer write code in

When you are typing in the terminal you need to type keep and give space keeping in mind the indentation needed for the code

Useful commands to write in terminal

Press enter -> To enter a new line
Double press enter -> To execute the code

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading