Automator – Get name of dropped file without file type

applescriptautomatorpython

I have a simple automator app that runs a python script on the file that is dropped on it. However, I need to also extract the name of the dropped file so that I can use it to create a directory name.

for f in "$@"
do
    set myFileName to name of (item f of $@)
    /usr/local/bin/python3 /Volumes/Scripts/script.py "$f"
    mkdir myFileName (without extension?)
done

Best Answer

The first line of your script is Applescript whereas it should be shell (bash by default). The tersest version I can think of:

for f in "$@"
do
    /usr/local/bin/python3 /Volumes/Scripts/script.py "$f"
    mkdir ${f%.*}
done