Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: copy a file into the same folder #60

Open
desgua opened this issue Nov 15, 2020 · 0 comments
Open

Enhancement: copy a file into the same folder #60

desgua opened this issue Nov 15, 2020 · 0 comments

Comments

@desgua
Copy link

desgua commented Nov 15, 2020

I've made a simple script that can be added to ~/.config/cfiles/scripts/cpself

#!/bin/bash
# version .2 fixed names with spaces
#
folder="$(printf "%s" "$1" | sed 's|\(.*\)/.*|\1|')"
file="$(printf "%s" "$1" | sed 's|.*/||')"

echo "Entering $folder "

cd "$folder"
if [ "$?" != "0" ]; then 
    echo "Failed to enter folder $folder "
    echo "Exiting..."
    read -r leave
    exit 1
fi

NAME () {
    printf "Copy %s -> " "$file"
    read  -r name
}

NAME;
while [ -f "$name" ]; do
    echo "The name \"$name\" already exists in this folder."
    NAME;
done

cp -v "$file" "$name"



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant