How do I create a txt file for each word in a list
Try this as a solution if each word in C:\Gardening\WordFile.txt is on it's own separate line in the file:
Text In WordFile.txt Example:
Aquaculture
Aquaponics
Hydroponics
Aeroponics
Implicit Batch Script
This batch script should be run from the same directory as the List.txt and files to be created will reside; so the batch script, the file-list, and the created files will all be in the same one folder for this.
@ECHO ON
::: Implicitly Written
SET FileList=List.txt
FOR /F "TOKENS=*" %%F IN (%FileList%) DO (
ECHO ^0>"%%~F.txt"
)
GOTO EOF
Explicit Batch Script
This batch script can be run from anywhere since the full path is specified pointing to the file-list and where the new files are created.
@ECHO ON
:::Explicitly Written
:::: Ensure there are NO SPACES in this path
SET FileList==H:\OMGA\AutoRefresh\FileList.txt
SET CreateFileDir=H:\OMGA\AutoRefresh\OutputFiles\
FOR /F "TOKENS=*" %%F IN (%FileList%) DO (
ECHO ^0>"%CreateFileDir%\%%~F.txt"
)
GOTO EOF
If each word in C:\Gardening\WordFile.txt is on the same exact line with each being separated by a space then use the below solution instead:
Text In WordFile.txt Example:
Aquaculture Aquaponics Hydroponics Aeroponics
FOR /F "DELIMS=" %%F IN (C:\Gardening\WordFile.txt) DO FOR %%G IN (%%F) DO ECHO. >> "C:\Gardening\%%~F.txt"
Added per commented request. . .
@ECHO ON
::: Implicit
:::: Ensure there are NO SPACES in this path
SET FileList=List.txt
FOR /F "TOKENS=*" %%F IN (%FileList%) DO (
ECHO. >>"%%~F.txt"
CALL :CreateFile "%%~F.txt"
)
GOTO EOF
:CreateFile
ECHO ^0>"%~1"
GOTO EOF
Best Answer
if you use the bash it could look like this
you simply change the "abc_" to your beginning filename.
Be careful it will re compress the already compressed files, because they start like the normal files.
Best regards Kenny