Advertisement
angeldp

sitioWeb.cmd

Jun 23rd, 2015
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.68 KB | None | 0 0
  1. @echo off
  2. REM sitioWeb.cmd
  3. REM  Autor: angeldp
  4. REM  Sintaxis: sitioWeb.bat NombreSitio
  5. ::
  6. :: El script recibe como parámetro el nombre de un sitio web y crea,
  7. :: dentro del directorio www, una carpeta con el nombre del sitio; y
  8. :: dentro de ella carpetas para css, js, img e images.
  9. :: Incluirá en las carpetas correspondientes los archivos
  10. :: style.css, script.js e index.html.
  11. :: Éste último contendrá la plantilla html del sitio.
  12. cls
  13. title=Gestor de sitios web
  14. color f0
  15. echo.
  16. echo Tildes omitidas intencionadamente.
  17. echo.
  18. REM Si no se ha pasado ningún parámetro  muestro la ayuda y finalizo.
  19. if "%1" == "" (
  20.     echo Uso: %0 NombreSitioWeb
  21.     echo Hay que indicar el nombre del sitio como parametro
  22.     exit
  23. )
  24. REM Creo la raiz del sitio web redireccionando el error por si ya existiera
  25. mkdir "%USERPROFILE%\www" 2> nul
  26. REM Intento entrar en el sitio para ver si ya existe
  27. cd "%USERPROFILE%\www\%1" 2> nul
  28. REM Si el comando anterior no ha dado error es que el sitio web ya existe
  29. if NOT ERRORLEVEL 1 (
  30.     echo El sitio web %1 ya existe.
  31.     echo No se llevara a cabo ninguna accion.
  32.     ) else (
  33.    REM Si el sitio no existe, lo creo junto con la estructura de directorios
  34.     echo Creando el sitio %1 y sus subdirectorios...
  35.     mkdir "%USERPROFILE%\www\%1\css" 2> nul
  36.     mkdir "%USERPROFILE%\www\%1\js" 2> nul
  37.     mkdir "%USERPROFILE%\www\%1\img" 2> nul
  38.     mkdir "%USERPROFILE%\www\%1\images" 2> nul
  39.     echo.
  40.    REM Y adjunto la plantilla y los archivos necesarios
  41.     echo Incluyendo style.css, script.js e index.html ...
  42.     echo. >> "%USERPROFILE%\www\%1\css\style.css"
  43.     echo. >> "%USERPROFILE%\www\%1\js\script.js"
  44.     echo ^<html^> >> "%USERPROFILE%\www\%1\index.html"
  45.     echo ^<head^> >> "%USERPROFILE%\www\%1\index.html"
  46.     echo ^<title^>%1^</title^> >> "%USERPROFILE%\www\%1\index.html"
  47.     echo ^<link rel='stylesheet' type='text/css' href='css/style.css' /^> >> "%USERPROFILE%\www\%1\index.html"
  48.     echo ^<script type='text/javascript' src='js/script.js'^>^</script^> >> "%USERPROFILE%\www\%1\index.html"
  49.     echo ^</head^> >> "%USERPROFILE%\www\%1\index.html"
  50.     echo ^<body^> >> "%USERPROFILE%\www\%1\index.html"
  51.     echo. >> "%USERPROFILE%\www\%1\index.html"
  52.     echo ^</body^> >> "%USERPROFILE%\www\%1\index.html"
  53.     echo ^</html^> >> "%USERPROFILE%\www\%1\index.html"
  54.     echo.
  55.    REM Asumo que si existe el archivo index.html en su carpeta,
  56.    REM todo se ha creado correctamente
  57.     if exist "%USERPROFILE%\www\%1\index.html" (
  58.         echo El sitio %1 y sus plantillas han sido creados con exito.
  59.         pause > nul
  60.     ) else (
  61.         echo No se ha completado la creacion del sitio %1
  62.         echo Pulse una tecla para salir.
  63.         pause > nul
  64.     )
  65. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement