HOWTO · Batch
Comprobar si existe un archivo usando Batch
Este tutorial discutirá y demostrará cómo puede verificar si existe un archivo usando un Batch script.
Este artículo demostrará cómo verificar si un archivo existe o no usando un Batch script a través de un código de ejemplo.
Comprobar si existe un archivo mediante un Batch script
El formato general o la sintaxis del código para verificar si existe un archivo se proporciona a continuación.
IF EXIST filename.txt (
action if file exists
) ELSE (
action if the file doesn't exist
)
El siguiente ejemplo comprobará si el archivo simple.txt existe o no. Si el archivo existe, mostrará el mensaje File exists!!!; si el archivo no existe, mostrará el mensaje: File missing!!!.
Código de ejemplo:
IF EXIST simple.txt (
echo File exists!!!
) ELSE (
echo File missing!!!
)
Producción :
File exists!!!
Recuerde, los métodos discutidos aquí están escritos usando Batch Script y solo funcionan en Windows CMD.