Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- REM sitioWeb.cmd
- REM Autor: angeldp
- REM Sintaxis: sitioWeb.bat NombreSitio
- ::
- :: El script recibe como parámetro el nombre de un sitio web y crea,
- :: dentro del directorio www, una carpeta con el nombre del sitio; y
- :: dentro de ella carpetas para css, js, img e images.
- :: Incluirá en las carpetas correspondientes los archivos
- :: style.css, script.js e index.html.
- :: Éste último contendrá la plantilla html del sitio.
- cls
- title=Gestor de sitios web
- color f0
- echo.
- echo Tildes omitidas intencionadamente.
- echo.
- REM Si no se ha pasado ningún parámetro muestro la ayuda y finalizo.
- if "%1" == "" (
- echo Uso: %0 NombreSitioWeb
- echo Hay que indicar el nombre del sitio como parametro
- exit
- )
- REM Creo la raiz del sitio web redireccionando el error por si ya existiera
- mkdir "%USERPROFILE%\www" 2> nul
- REM Intento entrar en el sitio para ver si ya existe
- cd "%USERPROFILE%\www\%1" 2> nul
- REM Si el comando anterior no ha dado error es que el sitio web ya existe
- if NOT ERRORLEVEL 1 (
- echo El sitio web %1 ya existe.
- echo No se llevara a cabo ninguna accion.
- ) else (
- REM Si el sitio no existe, lo creo junto con la estructura de directorios
- echo Creando el sitio %1 y sus subdirectorios...
- mkdir "%USERPROFILE%\www\%1\css" 2> nul
- mkdir "%USERPROFILE%\www\%1\js" 2> nul
- mkdir "%USERPROFILE%\www\%1\img" 2> nul
- mkdir "%USERPROFILE%\www\%1\images" 2> nul
- echo.
- REM Y adjunto la plantilla y los archivos necesarios
- echo Incluyendo style.css, script.js e index.html ...
- echo. >> "%USERPROFILE%\www\%1\css\style.css"
- echo. >> "%USERPROFILE%\www\%1\js\script.js"
- echo ^<html^> >> "%USERPROFILE%\www\%1\index.html"
- echo ^<head^> >> "%USERPROFILE%\www\%1\index.html"
- echo ^<title^>%1^</title^> >> "%USERPROFILE%\www\%1\index.html"
- echo ^<link rel='stylesheet' type='text/css' href='css/style.css' /^> >> "%USERPROFILE%\www\%1\index.html"
- echo ^<script type='text/javascript' src='js/script.js'^>^</script^> >> "%USERPROFILE%\www\%1\index.html"
- echo ^</head^> >> "%USERPROFILE%\www\%1\index.html"
- echo ^<body^> >> "%USERPROFILE%\www\%1\index.html"
- echo. >> "%USERPROFILE%\www\%1\index.html"
- echo ^</body^> >> "%USERPROFILE%\www\%1\index.html"
- echo ^</html^> >> "%USERPROFILE%\www\%1\index.html"
- echo.
- REM Asumo que si existe el archivo index.html en su carpeta,
- REM todo se ha creado correctamente
- if exist "%USERPROFILE%\www\%1\index.html" (
- echo El sitio %1 y sus plantillas han sido creados con exito.
- pause > nul
- ) else (
- echo No se ha completado la creacion del sitio %1
- echo Pulse una tecla para salir.
- pause > nul
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement