Linux commands: Difference between revisions

Jump to navigation Jump to search
712 bytes added ,  8 September 2016
Line 125: Line 125:
** {{kbd | key= dir C:\path\to\file}} or {{kbd | key= dir C:\path\to\directory\}}
** {{kbd | key= dir C:\path\to\file}} or {{kbd | key= dir C:\path\to\directory\}}
** {{kbd | key= IF EXIST}} e.g. [http://stackoverflow.com/questions/3022176/how-to-verify-if-a-file-exists-in-a-windows-bat-file How to verify if a file exists in a Windows .BAT file? - Stack Overflow]
** {{kbd | key= IF EXIST}} e.g. [http://stackoverflow.com/questions/3022176/how-to-verify-if-a-file-exists-in-a-windows-bat-file How to verify if a file exists in a Windows .BAT file? - Stack Overflow]
<pre>
SET a=C:\path\to\file
REM -- If the directory was separated the \ symbol & the path NOT contains space
IF EXIST %a% (ECHO YES) ELSE (ECHO No)
SET a="C:\path\to\directory contains space\space"
REM -- If the directory was separated the \ symbol & the path contains space
IF EXIST %a% (ECHO YES) ELSE (ECHO No)
SET a=C:/path/to/file
REM -- If the directory was separated the / symbol, the next command replace / with \ symbol.
SET a=%a:/=\%
IF EXIST %a% (ECHO YES) ELSE (ECHO No)
</pre>
troubleshooting
<pre>
SET a = C:\path\to\file
REM -- If the directory was separated the \ symbol & the path NOT contains space
IF EXIST %a% (ECHO YES) ELSE (ECHO No)
REM -- the returned result will not correct!
</pre>


=== Rename (move) files or directory ===
=== Rename (move) files or directory ===

Navigation menu