deurlname froms renameutils renames files properly, though it ignores %xy in folder path.

But so far I have found no function that works on strings in Bash script.

What I have tried so far:


shopt -s expand_aliases
alias urldecodePython='python3 -c "import sys, urllib.parse as ul; print(ul.unquote_plus(sys.argv[1]))"'
fnonly=$( urldecodePython "$fnonly" )
urldecode() {
    # urldecode <string> ,  assumes the data contains no backslash.

    local url_encoded="${1//+/ }"
    printf '%b' "${url_encoded//%/\\x}"
fnonly="$(urldecode "$fnonly")"
fnonly=$(echo "$fnonly" | sed -e's/%\([0-9A-F][0-9A-F]\)/\\\\\x\1/g')
rename 'use URI::Escape; $_ = uri_unescape $_' $fdir/*%*

(Before I switched to deurlname; not a string function but had the same problem.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.