flexy
Diamond Member
I want to do the following:
Say I have a folder which contains any number of "articles", which MAY be named like article01.txt, article02.txt ... article99.txt (or whatever other *.txt)
Each particular article in his FIRST line has the title in it
The script (preferably running under Windows) should read this first line of the (each) article (in the folder) and rename the file. Say, turn "article01.txt" into "What You Need to Know About Windows.txt"
Preferably also having a character limit how long the title can be and obviously also filter out special characters which are not suitable to use in a filename.
OK:
REM @ echo off
SetLocal ENABLEDELAYEDEXPANSION
for %%i in (.\*.txt) do (
set /p var= <"%%i"
REM ren %%i "!var!.txt"
ren %%i "!var!.txt"
)
Problem for now only the filtering...
Say I have a folder which contains any number of "articles", which MAY be named like article01.txt, article02.txt ... article99.txt (or whatever other *.txt)
Each particular article in his FIRST line has the title in it
Code:
What you need to know about Windows 8.1
Blah BlahBlah Blah
[the actual article]
Preferably also having a character limit how long the title can be and obviously also filter out special characters which are not suitable to use in a filename.
OK:
REM @ echo off
SetLocal ENABLEDELAYEDEXPANSION
for %%i in (.\*.txt) do (
set /p var= <"%%i"
REM ren %%i "!var!.txt"
ren %%i "!var!.txt"
)
Problem for now only the filtering...
Last edited: