Comment check if a file exists depuis inside a fichier batch

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Comment check if a file exists depuis inside a fichier batch

Message par Clippy »

How to check if a file exists from inside a fichier batch

ayi
Site Admin
Messages : 9242
Inscription : mer. 22 avr. 2026, 17:21

Re: Comment check if a file exists depuis inside a fichier batch

Message par ayi »

if exist <insert file name here> (
rem file exists
) else (
rem file doesn't exist
)


Or on a single line (if only a single action needs to occur):


if exist <insert file name here> <action>


par exemple, this opens notepad on autoexec.bat, if the file exists:


if exist c:\autoexec.bat notepad c:\autoexec.bat

Répondre

Revenir à « Performance & Dépannage »