windows - Checking if a folder exists using a .bat file

ID : 20143

viewed : 14

Tags : windowsbatch-filewindows

Top 5 Answer for windows - Checking if a folder exists using a .bat file

vote vote

95

For a file:

if exist yourfilename (   echo Yes  ) else (   echo No ) 

Replace yourfilename with the name of your file.

For a directory:

if exist yourfoldername\ (   echo Yes  ) else (   echo No ) 

Replace yourfoldername with the name of your folder.

A trailing backslash (\) seems to be enough to distinguish between directories and ordinary files.

vote vote

83

I think the answer is here (possibly duplicate):

How to test if a file is a directory in a batch script?

IF EXIST %VAR%\NUL ECHO It's a directory 

Replace %VAR% with your directory. Please read the original answer because includes details about handling white spaces in the folder name.

As foxidrive said, this might not be reliable on NT class windows. It works for me, but I know it has some limitations (which you can find in the referenced question)

if exist "c:\folder\" echo folder exists  

should be enough for modern windows.

vote vote

78

For MAC:

brew install bundletool bundletool build-apks --bundle=./app.aab --output=./app.apks bundletool install-apks --apks=app.apks 
vote vote

67

You cannot install app bundle [NAME].aab directly to android device because it is publishing format, but there is way to extract the required apk from bundle and install it to you device, the process is as follow

  1. Download bundletool from here
  2. run this in your terminal,
java -jar bundletool.jar build-apks --bundle=bundleapp.aab --output=out_bundle_archive_set.apks 
  1. Last step will generate a file named as out_bundle_archive_set.apks, just rename it to out_bundle_archive_set.zip and extract the zip file, jump into the folder out_bundle_archive_set > standalones, where you will seee a list of all the apks

There goes the reference from android developers for bundle tools link

android developer reference

vote vote

56

If you want to install apk from your aab to your device for testing purpose then you need to edit the configuration before running it on the connected device.

  1. Go to Edit Configurations
    enter image description here
  2. Select the Deploy dropdown and change it from "Default apk" to "APK from app bundle".enter image description here
  3. Apply the changes and then run it on the device connected. Build time will increase after making this change.

This will install an apk directly on the device connected from the aab.

Top 3 video Explaining windows - Checking if a folder exists using a .bat file

Related QUESTION?