Session Ready
Exercise

Safely find directories

At the film studio you work at there is a need to create a tool for animators to search incredibly large file systems as quickly as possible and find all of the directories in them. You benchmarked both regular python code and python code that uses the Unix find command to see which performed better at searches. You have determined for this particular problem that the Unix find performs the best. One concern you have though is ensuring that the command safely processes user input. In the past tools have been released that accidentally deleted large sections of the file server because a user accidentally put the wrong string into a tool.

Write a tool that safely processes user input and searches a file system for all directories using find and subprocess.Popen.

Instructions
100 XP
  • Write a script that safely can test user input in subprocess.Popen.
  • Find all of the files in the current working directory.
  • Print out all of the directories found.