mercredi 6 septembre 2017

See if file exists, rename using Command line windows

I have spent a lot of time trying to figure this out and am quite frustrated.

All I want to do is see if a file exists ,(which it does) and then rename it. I am working in the command line in Windows 10.

    IF exist C:\content\info.txt (
      ren "C:\content\info.txt" "C:\content\info_new.txt"
 ) ELSE (
      echo "Couldn't find file."
 )

I keep getting the "Syntax of the command is incorrect" I know the file exists, because I ran this earlier.

    if exist C:\content\info.txt echo "info.txt is in C:\content\info.txt."

I am entering all of this directly into the command prompt, and not calling it from a .bat file. Am I missing something here? Any help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire