I have a script that runs a python script (used to deduplicate emails via IMAP) after a user has entered a servername, username & password. The first part of it gets a list of folders which the second part then uses as inputs - all fine unless a folder name has a space in it at which point the entry needs to be in quotation marks As an example Inbox is fine whereas My Inbox needs to be read as "My Inbox"
#!/bin/sh
# Delete all duplicate messages in all folders of said account.
# Note that we connect through SSL (-x) to the default port.
read -p "Server: " SERVER
read -p "Username: " USER
read -s -p "Password: " PASS
echo
echo ...........
echo FOLDER LIST
echo ...........
echo
# Next line generates list for display only
/tmp/IMAPdedup-master/imapdedup.py -s $SERVER -x -u $USER -w $PASS -l
# Next line generates list to be used by the do line - this is the entries that need
to have each line in quotations
for folder in `/tmp/IMAPdedup-master/imapdedup.py -s $SERVER -x -u $USER -w $PASS -l`;
do /tmp/IMAPdedup-master/imapdedup.py -s $SERVER -x -u $USER -w $PASS $folder
done