Saturday, June 6, 2015

Working Smarter – Creating Folders


Working Smarter – Creating Folders

Sometimes in we need to create a large number of folders. An example is you are currently working in HR and need a folder for every person that is hired during a week. Sometimes it is one or two, but other times it can be 50. This Working Smarter session is going to detail how to create multiple folders quickly and easily.

Step One:

We need to make sure we can view your extensions, because we are going to be changing them. Click on your Windows button.


Next choose the Control Panel

.

When the control panel opens type the word “folder” in the upper right search field and hit enter. Then select the “Folder Options”

Select the “View Tab” and uncheck the “Hide Extensions for known file types”.


Hit Apply and then Okay.

Step Two: First create a folder on your desktop. Right click on your desktop and choose New >Folder.

Please name this folder “Make_Folders”


Double click on your folder to open it and create another folder called “Folders”


Next create a text file by right clicking in the white space under folders. Choose New > Text Documents and name it “names.txt”


Next create a text file by right clicking in the white space under “names.txt”. Choose New > Text Documents and name it “create_folders.txt”.


 
We need the location of the “Folders” folder. Double click on “Make_Folders” and then double click on the “Folders”. It should look like the following.

 

Click in the location bar and select the text by holding down CTRL+R, while it is highlighted right click and choose copy. Past this below in the “paste here” phrase. We are going to save it for later.


“paste here”

C:\Users\Teaching\Desktop\Make_Folders\Folders

(You will notice that the word “Teaching” appears in my string. This is my username. In your paste it should have your username.)

Open the “create_folders.txt” by double clicking on it.

Type the following string in the document:

for /F "tokens=*" %%f in (names.txt) do (mkdir  C:\Users\Teaching\Desktop\Make_Folders\Folders\%%f")

The highlighted section needs to be your string that you pasted from above.


 

 Click on File > Save As > and change the txt to bat at the end of the file name. You must also choose All Files in the save as type. Just click on the arrow and you will be able to select it. Then click on Save.



Step Three: Next open the “names.txt” file by double clicking on it.

Paste in the names you want to create folder for. In this example I’m going to paste the following names. Then save your file.

Josh Green MD.

John Smith PhD.

Lilly Johnson Intern

Katie Apple Student


Save and close your file.

 When you saved your “Create folders” as a bat file it changed the icon to little gears.

 

Double click on the create_folders item that has the gear icon.

You should see a black screen flash.

Now open your “folders”


 

Troubleshooting:

If your program didn’t work…do not fear you probably have an error somewhere, you just have to find it.

  1. Sometimes if you can’t see the file extension (.txt) there is an error in the naming of the file and your program can’t find it. Go over the folder options portion of the document (Step one).
  2. Check the location string in Step two. This must be exact! All the names of the folders the case sensitive matters. Make sure you are using _ not a space in the folder names.
  3. Keep trying and looking again and again the smallest error will make it not working.

DeCode the Code:

for /F "tokens=*" %%f in (names.txt) do (mkdir  C:\Users\Teaching\Desktop\Make_Folders\Folders\%%f")

for /F “tokens=*” %%f (Sets up the loop so that it creates a folder for every line. Sets %%f as the variable.

in (names.txt) This states the file that has the names of the folders you want to create.

Do what you want the program to do with the variables

(Mkdir ….) This is the command and then the location of the output. Mkdir command = Make Directory