0

I am a computational chemistry student and I need to create 100 directories and copy several python programs into each of them before submitting each one to my schools cluster to test the effectiveness of a program I am writing. Rather then typing mkdir test1, mkdir test2,... mkdir test100 and then cp ...... hundreds of times I'm hoping to make a python program to do all that work for me. I have seen several posts that are a bit too advanced for me to figure out how to do what they are saying so i'm hoping someone knows how to do what I am trying to do.

  • I don't understand why would someone down vote his humble question. Nicholas is just having difficulty grasping this idea of reaching his task. I can agree that the question isn't formatted well, but if read once you will get what he is trying to say. So, I would recommend others that instead of down voting and discouraging novices please give them a better modular breakdown of their question. They don't want our exact answers all the time. They are just looking for some directions!!! – anugrah Jun 20 '17 at 22:47

1 Answers1

0
  1. You can start by importing os, sys and path.
  2. create a for i loop with range till 100.
  3. get current working directory as the folder_path
  4. create name = "test"
  5. in loop do folder_name=name+str(i) use test_path=path.join(folder_path,folder_name) and then do following:

if not os.path.exists(test_path): os.makedirs(test_path)

This will make directory if not existing.

Then for copying the files into them, you can use the same loop and after step 5 you can move the files in them.

You can refer this simple example to copy many files into a given directory from another directory.

I hope this helps for you to get a clearer idea and also gives you work to do :P :D

anugrah
  • 187
  • 1
  • 1
  • 10