Right it should be a real valid mailbox, but it should only contain files that have been dumped there with the script, it shouldn't generate its own mails or move 'real' mails in there, only the dumped stuff should be there, otherwise when it performs VARCOUNT, it will probably do weird stuff
Blyiss wrote:Sorry, Grifter, after posting I notices that trash inside the mailbox doesn't work. But it is fine, when outside ~/Mail folder.
Code: Select all
$ ./movetotrash2
./movetotrash2: line 25: let: 10~: syntax error in expression (error token is "~")
Is there a way to put the files to the trash that is inside the mailbox? Otherwise Mutt doesn't except the folder, if it didn't compiled it by itself. I didn't try Emacs yet.
The error there seems to be the cause of a ~, maybe one of the mails has a ~ after it, when VARCOUNT gets the number, it strips the leading zeroes, but expects only digits in the filename, if a filename is called 00011~ it would probably error the same way you posted, if the reader is the one that puts ~ in the filename that character would have to be stripped away too, which is a pretty simple thing to do
I'm not really sure what you mean by trash files inside the mailbox, I guess it has to do with the the paths
for example, let's say you are in your ~/Mail dir, if you type there, find -name ',*' it would locate all the ,filenames with the relative path, ie it would say ./somedir/,1
but if you instead typed (in that same dir) find /home/luser/mail -name ',*', it would now print the full path
if you set UN=/home/luser/Mail/dumpdir and DEUX=/home/luser/Mail in the script, it should work fine, the beginning of the loop states, find $DEUX -name, so if DEUX has the full path, it would mean find /home/luser/Mail -name, and when i gets its value it should be the filename with the full path
but the errors you got, were line 25 and line 50, the "let" lines, where it's supposed to move the number one step higher, but assuming it thinks the number is 10~, it doesn't know how to change it up to 11, because of the ~ character which I assume exists on one (or more) file(s)
to bypass that, the line that says
VARCOUNT=`ls $UN | sed -r 's/(0*)(.*)/\2/' | tail -n 1`
change that to
VARCOUNT=`ls $UN | sed -r 's/(0*)(.*)/\2/' | tail -n 1 | sed 's/~//g'`
basically just piping it to a sed 's/~//g', to remove this tilde character, the filename with the tilde would remain unchanged but it wouldn't interfere with the variable that tries to determine which number we're at