加入收藏 | 设为首页 | 会员中心 | 我要投稿 应用网_镇江站长网 (https://www.0511zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Unix > 正文

dos2unix格式转换之VBScript脚本 - Unix系统

发布时间:2014-05-30 12:36:11 所属栏目:Unix 来源:站长网
导读:Unix软件开发,一般情况下我们会在windows下使用工具进行开发测试,然后上传到Unix下(测试),但是通常情况下工具保存的是dos格式,上传上去后往往会出现一些
Unix软件开发,一般情况下我们会在windows下使用工具进行开发测试,然后上传到Unix下(测试),但是通常情况下工具保存的是dos格式,上传上去后往往会出现一些问题(如ClearCase下下来后都增加了换行,Oracle存储过程、Unix Shell不能运行等),于是我们就需要将格式转换成unix格式再上传。这个vbscript脚本就是一个转换工具。当然,我们也可以使用Eclipse,Notepad++等工具进行转换。

dos2unix.vbs

This is a script for translating files from windows format to unix format.Maybe you always meet this situation that you create or edit your files on windows but can't work when upload to unix,  this tool can help you to solve this issue.

---------------------------------------------------------------------------------

on error resume next

Dim Fso

Set Fso = wscript.CreateObject("scripting.filesystemobject")

Dos2UnixFolder(".")

msgbox "Finished dos2unix!"

Function Dos2UnixFolder(ByVal path)

dim fd

set fd= fso.getfolder(path)

If fd.Files.Count > 0 Then

 For Each myf In fd.Files

  if right(lcase(myf.Name),6)<>".class" and right(lcase(myf.Name),4)<>".xml" then

   Dos2UnixFile(path&"/"&myf.Name)

  end if

 Next

End If

 If fd.subfolders.Count > 0 Then

 For Each myfd In fd.subfolders

  Dos2UnixFolder(path&"/"&myfd.Name)

 Next

End If

End Function

function Dos2UnixFile(filePath)

set f=fso.opentextfile(filePath)

s=replace(f.readall,vbcrlf,chr(10)) 'replace dos to unix format: vbcrlf=chr(13)chr(10)

f.close

set r=fso.opentextfile(filePath,2,true)

r.write s

end function

---------------------------------------------------------------------------------

本文出自 “小何贝贝的技术空间” 博客,请务必保留此出处http://babyhe.blog.51cto.com/1104064/247256

查看本栏目更多精彩内容:http://www.bianceng.cn/OS/unix/

(编辑:应用网_镇江站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读