标题: [文件操作] 批处理怎样修改OUTLOOK签名文件? [打印本页]
作者: springcm 时间: 2008-5-14 11:02 标题: 批处理怎样修改OUTLOOK签名文件?
一般OUTLOOK 的签名文件位于%userprofile%/Application Data\Microsoft\Signatures 下有的3个文件:分别为“*.txt , *.rtf, 和*.htm"
我用echo *****>>输出到*.txt ,打开新文件后发现所有新追加内容均为乱码, 请大家帮忙解决下。
或者能否提供一份现有代码, 万分感谢!
作者: springcm 时间: 2008-5-15 20:38
没人回复自己顶下,问题已解决.
作者: namejm 时间: 2008-5-15 22:00
是怎么解决掉的呢?不妨说出来,让后来者少走弯路。
作者: springcm 时间: 2008-5-17 20:09
其实很简单,先用type signature.txt>>temp.txt
然后可以用for语句对temp.txt文件正常处理.
example:
- :: To change txt file ============================
- :: Because the different code, try to use type file to rebuild *.txt files.
- setlocal enabledelayedexpansion
- set workpath=%userprofile%\Application Data\Microsoft\Signatures
- if exist %temp%\txtroot rd /s /q %temp%\txtroot
- mkdir %temp%\txtroot
- set txtroot=%temp%\txtroot
- set txtfiles=%temp%\txtfiles.txt
- if exist !txtfiles! del !txtfiles! /f /q
- dir /b "!workpath!\*.txt" >>!txtfiles!
- for /f "delims=/ tokens=*" %%a in (!txtfiles!) do (
- type "!workpath!\%%a">>"%temp%\txtroot\%%a"
- set path="%temp%\txtroot\%%a"
- for /f "delims=/ tokens=*" %%b in (%temp%\temp.txt) do echo %%b >>!path!
- copy /y !path! "!workpath!\%%a">nul
- )
- 在这里的3个文件中,对*.rtf文件最难处理.不能直接用输出符>>进行操作:
- 我的处理如下:
- :: To change rtf file ==============================
- :: Replace the first and the second content of original *.rtf
- :: By {\f0\fswiss\fcharset134 Simsun;} first line
- :: By {\f1\fmodern Simsun;} second line
- set rtffiles=%temp%\rtffiles.txt
- if exist !rtffiles! del !rtffiles! /f /q
- if exist %temp%\rtfroot rd /s /q %temp%\rtfroot
- mkdir %temp%\rtfroot
- set rtfroot=%temp%\rtfroot
- dir /b "!workpath!\*.rtf" >>!rtffiles!
- for /f "delims=~~ tokens=*" %%f in (!rtffiles!) do (
- set rtfpath="!workpath!\%%f"
- rem set rtfname=%%f
- echo Modifying !rtfpath!
- set flag=0
- for /f "tokens=* usebackq" %%g in (!rtfpath!) do (
- if !flag!==0 (echo %%g>>!rtfroot!\%%f
- echo {\f0\fswiss\fcharset134 Simsun;}>>!rtfroot!\%%f
- echo {\f1\fmodern Simsun;}>>!rtfroot!\%%f
- )
- set flag=1
- )
- )
- rem echo the content of original *.rtf which was begining of 3 lines but final line.
- rem echo them to the folder %temp%\rtfroot
- for /f "delims=~~ tokens=*" %%f in (!rtffiles!) do (
- set rtfpath="!workpath!\%%f"
- for /f "skip=3 tokens=* usebackq" %%g in (!rtfpath!) do (
- if not "%%g"=="{\*\htmltag3 \par }}" echo %%g>>!rtfroot!\%%f
- )
- for /f "delims= tokens=*" %%l in (%myfiles%\rtf.txt) do echo %%l>>!rtfroot!\%%f
- )
- copy /y !rtfroot!\*.* "!workpath!\*.*">nul
复制代码
[ 本帖最后由 springcm 于 2008-6-1 19:57 编辑 ]
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |