You need to change your Run Shell Script
action to pass input as arguments
- then the path of the currently selected Finder item(s) will be passed as $1
(...).
In your shell script, you then need to change (cd "$1"
) to the passed-in folder in order to perform your merge command in the right place.
I suggest you make your shell script more robust to ensure that (a) only a folder is passed in (as currently selected in Finder) and (b) just one item:
# Make sure that a _single folder_ is currently selected in Finder; exit otherwise.
[[ $# -eq 1 && -d "$1" ]] ||
{ osascript -e 'display alert "Please select a single folder."'; exit 1; }
# Change to the folder.
cd "$1" || exit
# Perform the merge command.
cat *.txt >merged.csv