Dialog for requesting to replace a file (Zenity) [closed]

asked 2014-01-31 22:27:05 -0500

amod gravatar image

Hi all, Just for a fun and to know zenity better I made a simple programme which changes a file content to uppercase. The code as follows

#!/bin/bash
zenity --info --text "This programme will convert\n a selected file to uppercase"

 X=$(zenity --file-selection --title "Please Select a file")

if [[ $? -eq 1 ]] ; then
    zenity --question --text "You did not select any file \n Do you wish to continue."
case $? in
0)
   X=$(zenity --file-selection --title "Please Select a file");;
1)
    exit;;
esac    
fi
Y=$(zenity --file-selection --save --title "Please give a file name")
if [[ $? -eq 1 ]] ; then
   zenity --question --text "Do you want to exit this programme?"
case $? in
0)
exit;;
1)
Y=$(zenity --file-selection --save --title "Please give a file name");;
esac
fi

dd if=$X of=$Y conv=ucase
zenity --info --text "Your file has been converted to uppercase\n It has been saved in $Y"

Here the code works fine. I know there might be bugs in it but when i select a existing file to save it does not ask me weather to replace the existing file or not. What function should i use for this

Regards

Amod

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by marcindulak
close date 2014-02-08 18:31:41.460497

Comments

More a general linux question. You might get better answers at a dedicated bash/linux forum like stackexchange. Not closing it though, someone might have ideas :)

FranciscoD_ gravatar imageFranciscoD_ ( 2014-02-01 03:18:09 -0500 )edit
marcindulak gravatar imagemarcindulak ( 2014-02-08 18:31:18 -0500 )edit