Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for simplesitemap.bat

(view source code of simplesitemap.bat as plain text)

  1. @ECHO OFF
  2. :: Check Windows version and command line arguments
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4. IF NOT  "%~2"==""           GOTO Syntax
  5. IF      "%~1"==""           GOTO Syntax
  6.  
  7. SETLOCAL
  8. PUSHD "%~dp0"
  9. SET WebSite=%~1
  10. SET XML="%~dpn0.xml"
  11. TITLE Creating %~n0.xml
  12. >  %XML% ECHO ^<?xml version="1.0" encoding="utf-8"?^>
  13. >> %XML% ECHO ^<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"^>
  14. DATE /T | FIND "/" >NUL
  15. IF ERRORLEVEL 1 (
  16. 	FOR /F "skip=1 tokens=1-5* delims=- " %%A IN ('DIR *.php *.htm? ^| FIND "-"') DO (
  17. 		TITLE %%F
  18. 		>> %XML% ECHO   ^<url^>
  19. 		>> %XML% ECHO     ^<loc^>%WebSite%/%%F^</loc^>
  20. 		>> %XML% ECHO     ^<lastmod^>%%C-%%B-%%A^</lastmod^>
  21. 		>> %XML% ECHO   ^</url^>
  22. 	)
  23. ) ELSE (
  24. 	FOR /F "tokens=1-5* delims=/ " %%A IN ('DIR *.php *.htm? ^| FIND "/"') DO (
  25. 		TITLE %%F
  26. 		>> %XML% ECHO   ^<url^>
  27. 		>> %XML% ECHO     ^<loc^>%WebSite%/%%F^</loc^>
  28. 		>> %XML% ECHO     ^<lastmod^>%%C-%%A-%%B^</lastmod^>
  29. 		>> %XML% ECHO   ^</url^>
  30. 	)
  31. )
  32. >> %XML% ECHO ^</urlset^>
  33. ENDLOCAL
  34. POPD
  35. GOTO:EOF
  36.  
  37.  
  38. :Syntax
  39. ECHO SimpleSitemap.bat,  Version 1.10 for Windows 2000 and later
  40. ECHO Create a basic sitemap.org compliant XML sitemap
  41. ECHO.
  42. ECHO Usage:   SIMPLESITEMAP  http://www.website.org
  43. ECHO.
  44. ECHO Where:   http://www.website.org should be replaced by your own website's URL
  45. ECHO          including protocol (e.g. http://) but without trailing backslash
  46. ECHO.
  47. ECHO Notes:   Script must be located in the directory with the files to be indexed.
  48. ECHO          Output XML file will also be placed in the same directory.
  49. ECHO          File names must NOT contain "special" (high ASCII/Unicode) characters!
  50. ECHO          Script is hardcoded for PHP and HTM(L) files; modify if necessary.
  51. ECHO          Script assumes either MM/DD/YYYY or DD-MM-YYYY date format.
  52. ECHO          If you need to exclude files, use my Sitemap.bat instead.
  53. ECHO.
  54. ECHO Written by Rob van der Woude
  55. ECHO http://www.robvanderwoude.com
  56.  

page last modified: 2024-04-16; loaded in 0.0101 seconds