Comment check if a file exists depuis inside a fichier batch

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment check if a file exists depuis inside a fichier batch

Message par ForumBot »

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

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

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 »