Skip to content

File/Folder names with invalid characters break the script #12

@pakshuang

Description

@pakshuang

Thanks for creating this script, it's really useful!

However, I seem to be experiencing issues on Windows when the file/folder names contain invalid characters such as colons.
https://docs.microsoft.com/en-sg/windows/win32/fileio/naming-a-file#naming-conventions

- C:\Users\paksh\Documents\luminustest\SP1541-ES1541\Submission Folder:  Pre-course Writing Task\SP1541_AY2122Sem2_PreCourseWritingTask_SubmissionTemplate.docx
Traceback (most recent call last):
  File "C:\Users\paksh\Documents\GitHub\pyfluminus\pyfluminus_cli.py", line 109, in <module>
    download_files(module_file, auth, args.download_to, True)
  File "C:\Users\paksh\Documents\GitHub\pyfluminus\pyfluminus_cli.py", line 36, in download_files
    download_files(child, auth, download_path, verbose)
  File "C:\Users\paksh\Documents\GitHub\pyfluminus\pyfluminus_cli.py", line 36, in download_files
    download_files(child, auth, download_path, verbose)
  File "C:\Users\paksh\Documents\GitHub\pyfluminus\pyfluminus_cli.py", line 27, in download_files
    file.download(auth, download_path, verbose)
  File "C:\Users\paksh\Documents\GitHub\pyfluminus\pyfluminus\structs.py", line 314, in download
    return utils.download(url, destination, verbose)
  File "C:\Users\paksh\Documents\GitHub\pyfluminus\pyfluminus\utils.py", line 26, in download
    os.makedirs(dir_path, exist_ok=True)
  File "C:\Users\paksh\AppData\Local\Programs\Python\Python39\lib\os.py", line 225, in makedirs
    mkdir(name, mode)
NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\\Users\\paksh\\Documents\\luminustest\\SP1541-ES1541\\Submission Folder:  Pre-course Writing Task'

It works fine on Linux systems though, I discovered this issue because I run this script on my linux server and sync the files to my Windows laptop, but the sync wasn't working for certain folders with naming issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions