Raury Posted April 17, 2014 Posted April 17, 2014 1 would like to create 37 subfolders in the folder PanelA. I have a list in notepad for each subfolder name. I have here a basic script but I cannot get it to read the subfolder names in the notepad (or in the script) ParentFolder = "C:\" Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(ParentFolder) objFolder.NewFolder "R-" What shoul dI do to name these folders from the names: R-Ta R-61 R-31 R-Ty R-P1 R-B3 R-N2 R-50 R-1 R-BN1 etc Thanks Regards Raury
Meldrew Posted April 17, 2014 Posted April 17, 2014 You could do it in DOS in one line: FOR /F "tokens=1 " %%i in (subfolders.txt) do mkdir c:\%%i Where subfolders.txt is your text file of sub folder names... HTH, Meldrew
Raury Posted April 17, 2014 Author Posted April 17, 2014 Hi Meldrew, I had the error message %%i was unexpected at this time. - please see attached. Raury
Fleetwood Posted April 17, 2014 Posted April 17, 2014 (edited) If you're running it directly from CMD you need to use %i rather than %%i, I think? EDIT: Yes, if you're inputting it directly in CMD you need to use %i, if running from a .bat then you use %%i Edited April 17, 2014 by Fleetwood 1
mac_shinobi Posted April 18, 2014 Posted April 18, 2014 Presume this is resolved using the bat script etc or did you want / need this in a different script ie vbs / powershell etc ? 1
Garacesh Posted April 24, 2014 Posted April 24, 2014 (edited) FOR /F "tokens=1 " %%i in (subfolders.txt) do mkdir c:\%%i See, I would have convoluted the heck out of it by writing it in powershell, $SubfolderList = (Get-Content ...\subfolders.txt) [int]$counter = 0 do { [indent]New-Item -ItemType directory -Path ...\$SubfolderList[$counter] $counter ++[/indent] } until ($counter -eq $SubfolderList.Count+1) Because I can never get around all this FOR, %%i, etc it Batch. It just.. Makes no sense (Could probably use ForEach-Item in $SubfolderList, but I'm not entirely sure how I'd do it. So for now I'd bodge it with a counter) Edited April 24, 2014 by Garacesh 1
mac_shinobi Posted April 24, 2014 Posted April 24, 2014 See, I would have convoluted the heck out of it by writing it in powershell, $SubfolderList = (Get-Content ...\subfolders.txt) [int]$counter = 0 do { [indent]New-Item -ItemType directory -Path ...\$SubfolderList[$counter] $counter ++[/indent] } until ($counter -eq $SubfolderList.Count+1) Because I can never get around all this FOR, %%i, etc it Batch. It just.. Makes no sense (Could probably use ForEach-Item in $SubfolderList, but I'm not entirely sure how I'd do it. So for now I'd bodge it with a counter) I'm the same ref makes no sense in batch with the FOR i%% etc, prefer vbs or powershell etc
LeMarchand Posted April 24, 2014 Posted April 24, 2014 I cheat and use a small app called "Text2Folders". Though if I learned to script it, it would better in the "Give a man a fish/teach a man to fish" way!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now