title: To convert a batch Labelme json files to a set of images and labels using anaconda prompt
body: <p>I have a dataset of image masks that were generated by the Labelme tool as JSON files and on the Github tutorial (<a href="https://github.com/wkentaro/labelme/tree/master/examples/tutorial" rel="nofollow noreferrer">https://github.com/wkentaro/labelme/tree/master/examples/tutorial</a>) it shows to change the JSON file into an image file we use the following command line code</p>
  
  <pre><code>labelme_json_to_dataset apc2016_obj3.json -o apc2016_obj3_json
  </code></pre>
  
  <p>however this only works for one file at a time, so I have been trying to find a way to process all the files using one set of code, I've tried the following code </p>
  
  <pre><code>setlocal
  set "yourDir=C:\Users\Acer\Desktop\datasets\combined masks\"
  set "yourExt=*.json"
  pushd %yourDir%
  for %%a in (*%yourExt%)do labelme_json_to_dataset %%a -o %%a
  popd
  endlocal
  </code></pre>
  
  <p>the code works now by reading the name of the file and adding the file extension .json however, saving the file to a directory with the same name including the .json extension is giving me the following error</p>
  
  <pre><code>Traceback (most recent call last):
    File "c:\users\acer\.conda\envs\labelme\lib\runpy.py", line 193, in _run_module_as_main
      "__main__", mod_spec)
    File "c:\users\acer\.conda\envs\labelme\lib\runpy.py", line 85, in _run_code
      exec(code, run_globals)
    File "C:\Users\ACER\.conda\envs\labelme\Scripts\labelme_json_to_dataset.exe\__main__.py", line 7, in &lt;module&gt;
    File "c:\users\acer\.conda\envs\labelme\lib\site-packages\labelme\cli\json_to_dataset.py", line 65, in main
      PIL.Image.fromarray(img).save(osp.join(out_dir, 'img.png'))
    File "c:\users\acer\.conda\envs\labelme\lib\site-packages\PIL\Image.py", line 2131, in save
      fp = builtins.open(filename, "w+b")
  FileNotFoundError: [Errno 2] No such file or directory: '000828.json\\img.png'
  </code></pre>
  
  <p>I'm not familiar with cmd and require help saving the output to a directory with the file name without the .json extenstion</p>
  
  <p>below is a single file example that shows how a successful run is supposed to look like
  <a href="https://i.stack.imgur.com/Tq9CS.jpg" rel="nofollow noreferrer">enter image description here</a></p>
  
  <pre><code>(labelme) C:\Users\ACER\Desktop\datasets\combined masks&gt;labelme_json_to_dataset 000814.json -o 000814
  [[1m[33mWARNING[0m] [36mjson_to_dataset[0m:[36mmain[0m:[36m15[0m - [1m[33mThis script is aimed to demonstrate how to convert the JSON file to a single image dataset.[0m
  [[1m[33mWARNING[0m] [36mjson_to_dataset[0m:[36mmain[0m:[36m17[0m - [1m[33mIt won't handle multiple JSON files to generate a real-use dataset.[0m
  [[1m[37mINFO   [0m] [36mjson_to_dataset[0m:[36mmain[0m:[36m73[0m - [1m[37mSaved to: 000814[0m
  
  (labelme) C:\Users\ACER\Desktop\datasets\combined masks&gt;
  </code></pre>