Yes. My assumption in the code is that both <title> and </title> are on the same line but even that could be false.[/quote]
It is on same line. I see no reason why somebody wouldn't do so.
how to rename files
Moderator: DosItHelp
Re: how to rename files
doscode wrote:I have files *.html like "Collection-396.html". Every file contains description which is like "<title>Aasiaat (BGAA)</title>". Is any way how to get the title, for example "Aasiaat (BGAA)" and to rename the html filenames to their titles? So the resulting file would be like Aasiaat (BGAA).html
?Do you have "Total Commander" _http://www.ghisler.com/ — Use his multirename tool with _http://www.totalcmd.net/plugring/wdx-seo-html.html plugin.
Or, if you sharply like batch — "WDX columns extractor" _http://forum.wincmd.ru/viewtopic.php?p=87314#87314 (last link on page) with those plugin
Re: how to rename files
Foxidrive, I have tested your code and I think it is interesting idea to make new file to it. Maybe it would be not necessary so I will try yet simplify for new the version. This is just how the files will be renamed.
ren "Collection-407.html" "Thule (BGTL)(MIL).html"
ren "Collection-408.html" "Upernavik (BGUK).html"
ren "Collection-405.html" "Qaanaaq (BGQQ).html"
ren "Collection-406.html" "Sisimiut (BGSS).html"
ren "Collection-403.html" "Nuuk (BGGH).html"
ren "Collection-404.html" "Paamiut (BGPT).html"
ren "Collection-409.html" "Uummannaq-Qaarsut (BGUQ).html"
ren "Collection-399.html" "Kulusuk (BGKK).html"
ren "Collection-398.html" "Kangerlussuaq (BGSF).html"
ren "Collection-397.html" "Ilulissat (BGJN).html"
ren "Collection-393.html" "AD 2 AERODROMES.html"
ren "Collection-396.html" "Aasiaat (BGAA).html"
ren "Collection-94.html" "Aeronautical Information Packages (AIS).html"
ren "Collection-91.html" "_English.html"
ren "Collection-402.html" "Nerlerit Inaat (BGCO).html"
ren "Collection-400.html" "Maniitsoq (BGMQ).html"
ren "Collection-401.html" "Narsarsuaq (BGBW).html"
ren "Collection-391.html" "AIP PART 3 - AERODROMES (AD).html"
ren "Collection-108.html" "AIP Greenland.html"
ren "Collection-12.html" "Luftfartsinformation (AIS).html"
ren "Collection-30.html" "AIP Grønland.html"
ren "Collection-390.html" "AIP PART 3 - FLYVEPLADSER (AD).html"
And thanks for your inventions.
ren "Collection-407.html" "Thule (BGTL)(MIL).html"
ren "Collection-408.html" "Upernavik (BGUK).html"
ren "Collection-405.html" "Qaanaaq (BGQQ).html"
ren "Collection-406.html" "Sisimiut (BGSS).html"
ren "Collection-403.html" "Nuuk (BGGH).html"
ren "Collection-404.html" "Paamiut (BGPT).html"
ren "Collection-409.html" "Uummannaq-Qaarsut (BGUQ).html"
ren "Collection-399.html" "Kulusuk (BGKK).html"
ren "Collection-398.html" "Kangerlussuaq (BGSF).html"
ren "Collection-397.html" "Ilulissat (BGJN).html"
ren "Collection-393.html" "AD 2 AERODROMES.html"
ren "Collection-396.html" "Aasiaat (BGAA).html"
ren "Collection-94.html" "Aeronautical Information Packages (AIS).html"
ren "Collection-91.html" "_English.html"
ren "Collection-402.html" "Nerlerit Inaat (BGCO).html"
ren "Collection-400.html" "Maniitsoq (BGMQ).html"
ren "Collection-401.html" "Narsarsuaq (BGBW).html"
ren "Collection-391.html" "AIP PART 3 - AERODROMES (AD).html"
ren "Collection-108.html" "AIP Greenland.html"
ren "Collection-12.html" "Luftfartsinformation (AIS).html"
ren "Collection-30.html" "AIP Grønland.html"
ren "Collection-390.html" "AIP PART 3 - FLYVEPLADSER (AD).html"
And thanks for your inventions.
Re: how to rename files
Code: Select all
@echo off
setlocal EnableDelayedExpansion
for %%a in (*.html) do (
for /F "delims=" %%b in ('findstr /C:"<title>" "%%a"') do (
set "line=%%b"
set "line=!line:<title>=$!"
set "line=!line:</title>=$!"
for /F "tokens=2 delims=$" %%c in ("!line!") do set "title=%%c"
)
ren "%%a" "!title!.html"
)
If the $ character may appear in the line containing the Title, it must be change by another unused character.