S
S
Slait2017-12-20 14:48:37
cmd/bat
Slait, 2017-12-20 14:48:37

How to create folder tree from txt file?

Hello. Tell me if there is a solution to this problem
There is a file in which there are 50,000 lines
Each line has a set of characters
Example:
abDe2
abDr5
You need to create a folder tree on your hard drive and an empty file at the end.
Those. it should look like this C:\a\b\!d\e\2
and for the second example C:\a\b\!d\r\5
!d is needed to distinguish small d from large
D a folder with a bunch of subfolders on the hard drive (interestingly, from ~ 500,000 folders the hard drive will not die)
Tell me if there are any ready-made programs that can do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Olgeir, 2017-12-20
@Olgeir

the first parameter is the name of the file with the list, the second directory from where it starts to create a hierarchy of directories.
Lines must not contain spaces or characters \|/ :?*"<>
@echo off
set sp=%~2
if ["%sp%"]==[""] set sp=.
for /f %%a in (%~1) do echo %%a&&set p=%sp%&&call :m %%a
exit
:m
set s=%~1
set b=%s:~0.1%
set o=%s:~1 %
@echo %b%|findstr /R "[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" && set b=!%b%
set p=%p%\%b%
md %p% 1>nul 2>nul
if not ["%o% "]==[""] call :m "%o%"
goto :eof

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question