S
S
sevafanasev2016-12-22 13:11:10
cmd/bat
sevafanasev, 2016-12-22 13:11:10

Is it possible to check if a folder exists in CMD?

Good time!
I rarely do scripting languages, so the question arose:
There is a script for copying files, depending on the bitness of the OS.
Tell me how to make the script check for the presence of a folder, i.e. if there is no folder, copy it depending on the bit depth, and if there is, then end the script.
The code itself:

@echo off
set old_dir="\\ws-it-18\etc\LibreOffice\extensions"
set new_dirx32="C:\Program Files\LibreOffice 5\share\extensions"
set new_dirx64="C:\Program Files (x86)\LibreOffice 5\share\extensions"
if "%PROCESSOR_ARCHITECTURE%"=="x86" (
  xcopy %old_dir% %new_dirx32% /s /e /h /y
) else (
  xcopy %old_dir% %new_dirx64% /s /e /h /y
)
exit /b

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Eremin, 2016-12-22
@EreminD

C:
   IF NOT EXIST C:\WIN\NUL GOTO NOWINDIR
   CD \WIN
   :NOWINDIR

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question