title: How to use \copy in psql after connecting to a database via URI in a batch file?
body: <p>I want to make a .bat file that will go to a directory, change code page (beacuse my folders contain characters from my native language) then open database in psql and then using \copy export some tables from DB to folder on my computer, then quit database and close the command. If I do it manually it works like a charm, but .bat file stops after entering database.</p>
  
  <pre><code>    cd C:\Program Files\PostgreSQL\9.6\bin
      chcp 1250
      psql "postgres://&lt;heres_my_URI&gt;"
      \copy &lt;table_name&gt; to 'G:\&lt;path&gt;\name.csv' with 
   DELIMITER ',' header csv; 
      \copy &lt;table_name&gt; to 'G:\&lt;path&gt;\name.csv' with 
   DELIMITER ',' header csv;  
      \q
      exit 
  </code></pre>
  
  <p>I want the .bat file to download csv's to the path and close itself after.</p>
  
  <p>But .bat is doing fine until it enters database, then it just shows: </p>
  
  <pre><code>&lt;mydatabase_name&gt; =&gt;
  </code></pre>
  
  <p>and until I press <code>\q</code> or </p>
  
  <pre><code>\copy &lt;table_name&gt; to 'G:\&lt;path&gt;\name.csv' with 
       DELIMITER ',' header csv;
  </code></pre>
  
  <p>manually, nothing will happen. After I quit DB, it shows me all the errors about \copy not being recognizable. How do I make it work? Thanks for help :)</p>