Hello, I am always putting together folder structures on shared network drives for storing all kind of mindless crap at work. I have been using a batch file to create these folders and subfolders from a text file which contains a list of names. The batch file is as follows: Code: for /F "tokens=*" %%* in (file.txt) do(mkdir "P:\Services\%%*" "P:\Services\%%*\Contracts" "P:\Services\%%*\Monitoring" "P:\Services\%%*\Reviews" ) This would neatly create folders for each company listed in file.txt and then 3 sub folders as above. Something like this: Code: P: Services HSBC CONTRACTS MONITORING REVIEWS BARCLAYS CONTRACTS MONITORING REVIEWS LLOYDS CONTRACTS MONITORING REVIEWS This was great but was a while ago now and the amount of information stored is getting large. I now need to insert a subfolder in CONTRACTS and MONITORING for every provider called OLDER CONTRACTS and OLDER MONITORING. Does anyone know how that would work with a batch file. Presumable it is very simple! ASs it doesnt need a list etc - just do the same for every folder in a directory/drive. Ive experimented but can get it quite right and am rubbish with programming. Its not my job - Im a contracts officer but this makes my life a whole lot easier. Much kudos to anyone who can help. Dean.
Code: for /F "tokens=*" %%* in (file.txt) do(mkdir "P:\Services\%%*" "P:\Services\%%*\Older Contracts" "P:\Services\%%*\Older Monitoring" ) ?
Hi Zoon, Line breaks added to make it readable on a forum post if thats what you mean? Dean. EDIT: Sorry - I need to put my glasses on! Yeah I should have mentioned that the original list of 300 odd folders came from a database. Since then folders names have been tweaked by users and some uneeded ones deleted etc. I dont even think I have the original text file either. Im just looking for a way of mindlessly creating a couple of sub directories in ALL of the folders regardless of names. A work around I suppose would be a way of merging all the current folder names into a text file by using a batch file. Then using this as you say. It has to be a batch file as no little apps allowed at work etc etc I keep nearly getting it but not quite - as I say I am not skilled/experienced in this area. Thanks, Dean.
Okay so basically you need to create the list again in that case. The easiest way IMO will be to: 1. Open a command prompt and type Code: dir /A:D > c:\folder_list.txt 2. Open Microsoft Excel and open c:\folder_list.txt as a tab-delimited text file, making sure that the column seperator puts the folder names in a column, doesn't really matter about the rest. 3. Chop the first three lines and the bottom two, so all you're left with is a list of folders, and some garbage data you don't care about. 4. Delete the other column(s). 5. Run your new script as above. (I would suggest you test it on a test folder with a handful of folders first just in case!!!) 6. Profit????
Thanks Zoon, Unfortunately I dont think I have root access but can probably make that work around work somehow. It just seems that surely there is an easier way to create a folder in every folder. Removing the tokens section of the batch etc and just mkdir "a directory" repeat or continue etc etc Is there such a way or am I a silly billy?!? Dont know what you mean by profit? Looking for moolah? I work for the local council social services and get F all. Although if anyone could solve the problem with a mini batch I could make a token PayPal gesture of festive god will! Thanks, Dean.
The "profit???" bit is just a pop-culture reference mate If you don't have root access or can't write to your C:, write to your personal directory or personal network drive. If you can't get into command prompt, write a new batch file called makelist.bat and drop the code I gave you, replacing c:\ with h:\ or whatever your personal drive is on your network! KISS - Keep It Simple, Stupid - you have a script that already works, you just need to give it a list of folders