mercredi 29 avril 2020

How do I write a script that writes scripts if a file has the .iso extention in linux?

So i'm trying to make executables for games with an .iso extention, so I can add them to steam directly, but I didn't feel like writing every individual one manually, so I wrote a script to do it for me:

    #!/bin/bash

for file in "$/media/dexterdy/d60690f8-0511-44bf-aa66-b8a211460113/samsung/gamecube/"; do
    if [ ${file: -4} == ".iso" ]
    then
        cat > ${file}.sh << EOF
        dolphin-emu --batch --exec="/media/dexterdy/d60690f8-0511-44bf-aa66-b8a211460113/samsung/gamecube/${file}"
EOF
    fi
done;

If I run it, I don't get any error messages, but it also doesn't generate any files. I think it has to do with the if statement ([ ${file: -4} == ".iso" ]), but I'm not sure. It could also be because the .iso files have spaces in their names.

P.S. Im new to writing scripts and coding in general. This is my second script I've ever written, so it would be appreciated if the explanations aren't too complicated.

Aucun commentaire:

Enregistrer un commentaire