Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

handling percent signs in filenames

Take Command 8.02.106 Windows XP [Version 5.1.2600]
Take Command Build 106 Windows XP Build 2600 Service Pack 3
Registered to Charles S. Galloway - 5 System License

I am not sure of how to handle the percent signs in filename - given this short and easy to understand BTM, also attached.

=======================================================================::
:: 1) send multiple files per email generated from DIR /S
:: 2) file names might have % signs ....
:: 3) if name of folder changes - email and the current folder name is the subject of the email
::
setlocal
set nLines=%@lines[twilight.lst]
for /l %line in (0,1,%lines) (
:: setdos /x-35678
set cLine=%@line[twilight.lst,%line]
:: setdos /x0
set cAtt=%cAtt /A %cLine
::
:: handle different folder name in line from twilight.lst
:: rightmost \ will be significant
set xAt=%@index[%cLine,\,-1]
iff %xAt qt 0 then
set cThisFldr=%@right[-xAt,%cLine]
iff %cThisFldr ne %cCurrFldr then
sendmail %cAtt /D /I1 /P1 /R /S1 /V "[email protected]" "Robert Cast Pictures" Files are attached
echo Emails: %@eval[%line / 5]
unset cAtt
set cCurrFldr=%cThisFldr
endiff
endiff
:: end handle....

iff %@eval[%line mod 5] eq 0 then
sendmail %cAtt /D /I1 /P1 /R /S1 /V "[email protected]" "Robert Cast Pictures" Files are attached
echo Emails: %@eval[%line / 5]
unset cAtt
endiff
)
iff %@eval[%line mod 5] ne 0 then
sendmail %cAtt /D /I1 /P1 /R /S1 /V "[email protected]" "Robert Cast Pictures" Files are attached
echo Emails: %@eval[%line / 5]
unset cAtt
endiff
endlocal
goto :here
:: sample of twilight.lst
Cast Member Photos\u7u7t.jpg
Cast Member Photos\v.jpg
Cast Member Photos\yhyt.jpg
Covers\gallery_main-robert-pattinson-gq-magazine.jpg
Covers\rob_kris_ok.jpg
Graphics\l36c19a950001_1_9427.jpg
Graphics\l36c19b170000_1_8980.jpg
Graphics\l36c19c5b0001_1_21803.jpg

would generate 3 emails. if there were more than 5 files in any one folder - that would generate more emails...
:here

=======================================================================
 

Attachments

  • sendlist.btm
    1.7 KB · Views: 245
CSGalloway wrote:
...

> setlocal
> set nLines=%@lines[twilight.lst]
> for /l %line in (0,1,%lines) (
> :: setdos /x-35678
> set cLine=%@line[twilight.lst,%line]
...


Regardless of the issue of percent % signs, I would recommend recasting this
program using DO:

setlocal
do cline in @twilight.lst
:: setdos ...
set cAtt=%cAtt /A %cLine
...
enddo

Two separate reasons:
1/ Using DO there is no limit on the number of characters in the code,
unlike the FOR loop using a command group (32767 in the file, 65535 after
variable expansion)
2/ The execution speed reasons described in help topic f_line.htm: to expand
%@line[file,100] all lines from line 0 to line 100 need to be read.
--
Steve
 

Similar threads

Back
Top