/// BANGBOO BLOG ///

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

August 26, 2010

今夜はKick it (WSH a.k.a VBscript)

動きゃ良い。周辺処理とバッチをキックするWinシェル。拡張子.vbs

'■設定
Dim regExDel
regExDel = "\.mp3|\.MP3|\.flv|\.wmv"

Dim thisFileName
Dim batFileName
Dim listFileName
thisFileName = "songs_file_kick.vbs"
batFileName = "songs_file_setting.bat"
listFileName ="songs_filelist.txt"

Dim objShell
Dim curDir
Set objShell = WScript.CreateObject("WScript.Shell")
curDir = objShell.CurrentDirectory

Dim batFile
Dim listFile
Dim tempFile
Dim tempFile2
batFile = curDir + "\" + batFileName
listFile = curDir + "\" + listFileName
tempFile = curDir + "\songs_filelist_tmp.txt"
tempFile2 = curDir + "\songs_filelist_tmp2.txt"

'■バッチ実行--ファイル名取得
'バッチ処理終了まで待つ
objShell.Run batFile + " " + listFileName,1,true
Set objShell = Nothing

'■拡張子の削除
Set fso = CreateObject("Scripting.FileSystemObject")
Set regEx = New RegExp
Set inFile = fso.OpenTextFile(listFile)
Set outFile = fso.CreateTextFile(tempFile)

regEx.Pattern = regExDel
repStr = ""
Do Until inFile.AtEndOfStream
    tempLine = inFile.ReadLine
    repLine = regEx.Replace(tempLine, repStr)
    repLine2 = regEx.Replace(repLine, repStr)
    outFile.WriteLine repLine2
Loop
inFile.Close
outFile.Close

'■ファイル名の削除
Set inFile = fso.OpenTextFile(tempFile)
Set outFile = fso.CreateTextFile(tempFile2)

tempText = inFile.ReadAll
tempText = Replace(tempText, thisFileName + vbCrLf, "")
tempText = Replace(tempText, batFileName + vbCrLf, "")
tempText = Replace(tempText, listFileName + vbCrLf, "")
tempText = Replace(tempText, "songs_filelist_tmp.txt"+vbCrLf, "")
tempText = Replace(tempText, "songs_filelist_tmp2.txt"+vbCrLf, "")
outFile.Write(tempText)
inFile.Close
outFile.Close

'■旧リストファイルを削除
fso.DeleteFile listFile, True
fso.DeleteFile tempFile, True

'■新リストファイルを本ファイルにリネーム
fso.MoveFile tempFile2,listFile

If Err.Number = 0 Then
WScript.Echo "リストを出力しました [" + listFileName + "]"
Else
WScript.Echo "エラー: " & Err.Description
End If

Set fso = Nothing

※関連ページ(キックするバッチファイル)
http://blog.bangboo.com/page_289.html

---------------------------------------------------
■嘘の情報に気をつけろ
カレントディレクトリに取得
vbsファイルの場所でなく、実行プログラム(例:c:\program\listcam)の場所を指す
Set objWshShell = CreateObject("WScript.Shell")
Msbbox objWshShell.CurrentDirectory

twitter
Hatena
Google Buzz
newsing
Yahoo!
Buzzurl
Technorati
del.icio.us
Choix
Iza!
Livedoor Clip
Facebook
Evernote
 

Posted by funa : 04:18 AM | Web | Comment (0) | Trackback (0)


PhotoGallery


TWITTER
Search

Mobile
QR for cellphone  QR for smart phone
For mobile click here
For smart phone click here
Popular Page
#1Web
#2Hiace 200
#3Gadget
#4The beginning of CSSレイアウト
#5Column
#6Web font test
#7Ora Ora Ora Ora Ora
#8Wifi cam
#9みたらし団子
#10Arcade Controller
#11G Suite
#12PC SPEC 2012.8
#13Javascript
#14REMIX DTM DAW - Acid
#15RSS Radio
#16Optimost
#17通話SIM
#18Attachment
#19Summer time blues
#20Enigma
#21Git
#22Warning!! Page Expired.
#23Speaker
#24Darwinian Theory Of Evolution
#25AV首相
#26htaccess mod_rewite
#27/// BANGBOO BLOG /// From 2016-01-01 To 2016-01-31
#28竹書房
#29F☆ck CSS
#30Automobile Inspection
#31No ID
#32Win7 / Win10 Insco
#33Speaker
#34Arcade Controller
#35Agile
#36G Suite
#37Personal Information Privacy Act
#38Europe
#39Warning!! Page Expired.
#40GoogleMap Moblile
#41CSS Selectors
#42MySQL DB Database
#43Ant
#44☆od damnit
#45Teeth Teeth
#46Itinerary with a eurail pass
#47PHP Developer
#48Affiliate
#49/// BANGBOO BLOG /// From 2019-01-01 To 2019-01-31
#50/// BANGBOO BLOG /// From 2019-09-01 To 2019-09-30
#51/// BANGBOO BLOG /// On 2020-03-01
#52/// BANGBOO BLOG /// On 2020-04-01
#53Windows env tips
#54恐慌からの脱出方法
#55MARUTAI
#56A Rainbow Between Clouds‏
#57ER
#58PDF in cellphone with microSD
#59DJ
#60ICOCA
#61Departures
#62Update your home page
#63CSS Grid
#64恐慌からの脱出方法
#65ハチロクカフェ
#66/// BANGBOO BLOG /// On 2016-03-31
#67/// BANGBOO BLOG /// From 2017-02-01 To 2017-02-28
#68/// BANGBOO BLOG /// From 2019-07-01 To 2019-07-31
#69/// BANGBOO BLOG /// From 2019-10-01 To 2019-10-31
#70/// BANGBOO BLOG /// On 2020-01-21
#71Bike
#72Where Hiphop lives!!
#73The team that always wins
#74Tora Tora Tora
#75Blog Ping
#76無料ストレージ
#77jQuery - write less, do more.
#78Adobe Premire6.0 (Guru R.I.P.)
#79PC SPEC 2007.7
#80Google Sitemap
#81Information privacy & antispam law
#82Wifi security camera with solar panel & small battery
#83Hope get back to normal
#84Vice versa
#85ハイエースのメンテ
#86Camoufla
#87α7Ⅱ
#88Jack up Hiace
#89Fucking tire
#90Big D
#914 Pole Plug
#925-year-old shit
#93Emancipation Proclamation
#94Windows env tips
#95Meritocracy
#96Focus zone
#97Raspberry Pi
#98Mind Control
#99Interview
#100Branding Excellent
Category
Recent Entry
Trackback
Comment
Archive
<     April 2024     >
Sun Mon Tue Wed Thi Fri Sat
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Link