I have modified a vbscript and batch file that allows me to convert HTML files to xlsx files in the current directory as follows
Script:
if WScript.Arguments.Count < 2 Then
WScript.Echo "Please specify the source and the destination files"
Wscript.Quit
End If
xlsx_format = 51
Set objFSO = CreateObject("Scripting.FileSystemObject")
src_file = objFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
dest_file = objFSO.GetAbsolutePathName(WScript.Arguments.Item(1))
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(src_file)
oBook.SaveAs dest_file, xlsx_format
oBook.Close False
oExcel.Quit
Batch file:
FOR /f "delims=" %%i IN ('DIR *.HTM* /b') DO to-xlsx.vbs "%%i" "%%~ni.xlsx"
del *.HTM /q
By including /s
in the batch file I am able to convert files in the subfolders but they are still saved to the parent directory and I cant quite work out how to change that?
src_file
is C:\Converter\Subfolder\FileName and dest_file
is C:\Converter\FileName for a file in the subfolder
A folder stored within another folder. Technically, the nested folder is a "subfolder," and subfolders can also contain subfolders and so on up to a maximum level.
Answer: is that subfolder is (computing) a folder within another folder while folder is (computing) a virtual container in a computer's file system, in which files and other folders may be stored the files and subfolders in a folder are usually related.
You will need to change
FOR /f "delims=" %%i IN ('DIR *.HTM* /b') DO to-xlsx.vbs "%%i" "%%~ni.xlsx"
to
FOR /R %%i IN (*.HTM* ) DO to-xlsx.vbs "%%i" "%%~ni.xlsx"
for /r
means Recursive, so you are asking CMD to loop every file and his subdirectories, but only that they contain an .htm*
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With