Skip to content

Instantly share code, notes, and snippets.

Created December 29, 2014 00:53
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Convert a folder of .URL files to a bookmarks.html file that can be imported into a browser
# Run this script in a folder full of ".url" files, and pipe output to an HTML file.
# Example: ./ > bookmarks.html
echo "<!DOCTYPE NETSCAPE-Bookmark-file-1>"
echo '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">'
echo '<TITLE>Bookmarks</TITLE>'
echo '<H1>Bookmarks</H1>'
echo '<DL><p>'
ls -1 *.url |
sed 's/.url//' |
while read L; do
echo -n ' <DT><A HREF="';
cat "$L.url" | grep URL | grep -v BASEURL | sed 's/URL=//' | tr -d '\r'| tr -d '\n'; echo '">'"$L"'</A>';
echo "</DL><p>"
Copy link

is there an opposite way like html to url

Copy link

gowhitehat commented Jan 9, 2023

Used ChatGPT to update:

Copy code
@echo off

rem Set the input and output file paths
set input_dir=C:\Documents and Settings\Admin\Favorites
set output_file=C:\output\bookmarks.html

rem Initialize the bookmarks file with the opening tags
echo ^ > %output_file%
echo ^<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"^> >> %output_file%
echo ^<TITLE^>Bookmarks^</TITLE^> >> %output_file%
echo ^<H1^>Bookmarks^</H1^> >> %output_file%
echo ^

<p^> >> %output_file%

rem Iterate through the input files and add each URL as a bookmark
for /f "tokens=*" %%f in ('dir /b %input_dir%*.url') do (
set url=
for /f "tokens=2 delims==" %%a in (%%f) do set url=%%a
echo ^<DT^><A HREF="%url%"^>%%f^</A^> >> %output_file%

rem Add the closing tags to the bookmarks file
echo ^

<p^> >> %output_file%

echo Conversion complete! Check %output_file% for the generated bookmarks file.

Copy link

@gowhitehat Why is that any better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment