I have found the need to create a script to do the exact opposite of this (to go from Linux to Windows), so that I can basically convert all of my 5.x Madsonic playlists (which I run on Linux) to 6.x format (which I run on Windows).
The problem I am having is that when I run the "batch" file, I get a subscript error on line 8, character 1. I think the issue is with how the parameters are being passed to the actual script.
Here is the script that I'm using:
Code: Select all
'usage: cscript replace.vbs Filename "StringToFind" "stringToReplace"
Option Explicit
Dim fso,strFilename,strSearch,strReplace,objFile,oldContent,newContent
strFilename=WScript.Arguments.Item(0)
strSearch=WScript.Arguments.Item(1)
strReplace=WScript.Arguments.Item(2)
'Does file exist?
Set fso=CreateObject("Scripting.FileSystemObject")
if fso.FileExists(strFilename)=false then
cscript.echo "file not found!"
cscript.Quit
end if
'Read file
set objFile=fso.OpenTextFile(strFilename,1)
oldContent=objFile.ReadAll
'Write file
newContent=replace(oldContent,strSearch,strReplace,1,-1,0)
set objFile=fso.OpenTextFile(strFilename,2)
objFile.Write newContent
objFile.Close
Here is the batch file I created (and keep in mind, this batch file works fine if I want to convert from windows format to linux format).
Code: Select all
@echo off
D:
cd \allshared\Media\6xPlaylists
for %%A in ("*.m3u8") DO cscript //nologo //X fixlist.vbs "%%A" "
/media/Music" "\\server\share\Media\Music"
for %%A in ("*.m3u8") DO cscript //nologo //X fixlist.vbs "%%A" "/" "\"
Thanks!