0

Hello awesome community i am using git bash to run this command: cp -r thisfolder thatfolder to copy the contents of a folder in another one

now i want to make a script out of this to create a scheduler to run that script and my script looks like this

#!/bin/bash
set -euo pipefail
IFS=$'\n\t

cp -r thisfolder thatfolder && echo done > debug.txt 
#the debug.txt is just to know if the script copied stuff

its a .bat script and all folders and script are on the same directory but for some reason it doesnt copy the files as git bash does

any thoughts??

Matt
  • 12,848
  • 2
  • 31
  • 53
  • 1
    If it's a `.bat` script, it won't get run by bash, it'll get run by Window's cmd/batch file interpreter. Actually, I guess it depends how your launch it. Can you show how you invoke this script exactly? – joanis Mar 13 '22 at 16:00
  • If it is running as a bash script, having the folders in the same directory as the script is irrelevant; the working directory of shell scripts is inherited from whatever ran the script, not the location of the script itself. See [BashFAQ #28](http://mywiki.wooledge.org/BashFAQ/028) and [this question](https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within). – Gordon Davisson Mar 13 '22 at 16:39
  • i double click on it tbh. what changes can i do if i want to make this work either as a .bat or a .sh(i tried making it as a .sh and running it from git bash but still get no results) – Theo Hexer Mar 13 '22 at 17:02
  • i also tried copy command and when i run it with powershell it works when i add it in the .bat and double click it it doesnt can someone explain pls? – Theo Hexer Mar 13 '22 at 17:12
  • 1
    quotes are not balanced – alecxs Mar 13 '22 at 17:24

0 Answers0