title: How to run .sh file on Windows10 startup
body: <p>How to run a Bash script when starting Windows 10?</p>
  
  <p>I can only find soulations for ubuntu.</p>
  
  <p>Thanks.</p>
  
  <pre><code>#!/bin/bash
  # Desktop PATH
  Desktop=/c/Users/118883/Desktop
  # folder with the script
  executeFolder=Clean-up-folder-structure 
  
  
  # mainfolder
  sortingFolder=sorting
  
  # inner folders
  docFolder=1.word_docs
  excelFolder=2.excel_docs
  imageFolder=3.images
  
  cd $Desktop
  
  # moves all folders from desktop to a sorting folder
  function moveMyFiles(){
  find *  -mindepth 0 -maxdepth 0 -not -name $sortingFolder -not -name 
  $executeFolder -exec mv -v -t $sortingFolder {} +
  }
  
  # Sort al the .docx files
  function sortDocs(){
  cd $sortingFolder
  if [ -d $docFolder ]
  then 
      find *.docx -mindepth 0 -maxdepth 0 -exec mv -v -t $docFolder {} +
  else
      mkdir $docFolder
      find *.docx -mindepth 0 -maxdepth 0 -exec mv -v -t $docFolder {} +
  fi
  }
  
  function sortExcel(){
  cd $sortingFolder
  if [ -d $excelFolder ]
  then 
      find *.xlsx -mindepth 0 -maxdepth 0 -exec mv -v -t $excelFolder {} +
  else
      mkdir $excelFolder
      find *.xlsx -mindepth 0 -maxdepth 0 -exec mv -v -t $excelFolder {} +
  fi
  }
  
  function sortImages(){
  cd $sortingFolder
  if [ -d $imageFolder ]
  then 
      find *.PNG -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
      find *.JPEG -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
      find *.jpeg -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
      find *.jpg -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
      find *.GIF -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
  else
      mkdir $imageFolder
      find *.PNG -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
      find *.JPEG -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
      find *.jpeg -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
      find *.jpg -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
      find *.GIF -mindepth 0 -maxdepth 0 -exec mv -v -t $imageFolder {} +
  fi
  } 
  
  #main execute 
  if [ -d $sortingFolder ]
  then 
  
  cd $Desktop
  moveMyFiles
  sortDocs
  sortExcel
  sortImages
  
  else
  
  # zo niet maak een folder
  cd $Desktop
  mkdir $sortingFolder
  moveMyFiles
  sortDocs
  sortExcel
  sortImages
  fi
  </code></pre>
  
  <p>When running in Powershell error appear.
  syntax errors and parse errors.
  like: </p>
  
  <p>At line:1 char:3
  + if [ -d $sortingFolder ]
  +   ~
  Missing '(' after 'if' in if statement.
  At line:1 char:5
  + if [ -d $sortingFolder ]
  +     ~
  Missing type name after '['.
      + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
      + FullyQualifiedErrorId : MissingOpenParenthesisInIfStatement</p>