command line interface – How to check: is the variable of the function the path to a folder or file on a remote server?

I need to use rsync or scp to copy a file or folder of files from a remote server to a computer.

To copy (synchronize) a folder, I use the following function:

foldertocomp () {
rsync -avz pi@192.168.1.5: "/ home / pi / Torrents / $ 1" / * "/ home / comp / Torrent / $ 1"
}

I can use the following functions to copy a file:

filetocomp () {
rsync -avz pi@192.168.1.5: "/ home / pi / Torrents / $ 1" "/ home / comp / Torrent /"
}

OR

filetocomp () {
scp pi@192.168.1.5: "/ home / pi / Torrents / $ 1" / home / comp / Torrent
}

All these functions work well. But I have to combine these functions into one function. Like that:

tocomp () {
Code ...
}

Use the function:

tocomp "HERE folder name OR file name"

I think I have to build the function like this:

tocomp () {
if "$ 1 is a file"
rsync -avz pi@192.168.1.5: "/ home / pi / Torrents / $ 1" "/ home / comp / Torrent /"
elif "$ 1 is a folder"
rsync -avz pi@192.168.1.5: "/ home / pi / Torrents / $ 1" / * "/ home / comp / Torrent / $ 1"
Fi
}

But how to check $ 1 is a folder or file?

I found the following method: stackoverflow.com/a/4665080/10728472.
But I think this method is not for the remote server.

How to check $ 1 is a folder or file on a remote server?