This is what I tried.
inputFile=$(zenity --file-selection --title "Test" --text "Please select the file for analysis." | sed -e "s/ /\\\ /g")
I did the
sed operation to replace white spaces with a
\ and a whitespace to make the copying command to work. Then from the Zenity file selection GUI I have chosen a file so that the value inside
/home/username/Documents/Learning\ and\ Development/testfile.txt.
Now when I try to copy this file to my working directory with
cp $inputFile .
Still it returns the error,
cp: cannot stat ‘/home/user/Documents/Learning\\’: No such file or directory cp: cannot stat ‘and\\’: No such file or directory cp: cannot stat ‘Development/WhatsApp.apk’: No such file or directory
Is there any way to bypass this? Actually I am writing a program. So I don't want to tell the users to rename their folder names to avoid spaces.