batch CSV to Excel


Is there a automated way to convert files in a folder from CSV to Excel?  thanks
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you open the CSV files directly in Excel, do they open up correctly or does it need to be modified?  If this is ok then you can just rename all csv to xls via command prompt.

ren *.csh *.xls
mcrmgAuthor Commented:
They need to be modified.. It gas "|" as delimiter...thx
This tool supports custom delimiter.  It may be a use to you:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewIT / Software Engineering ConsultantCommented:
Here is a VBS script approach that will get it done.  It assumes you have Excel installed on the computer you run this on though, no way around that.  Save this as a VBS file, and then run like this, passing it the path to the folder with the CSV files in it to process.  For each one the script will create an XLS version in the same folder.  Sample command line:

cscript EE28703584.vbs C:\Files

Const cExcel8 = 56

strExcel = "xls"
strCSV = "csv"

' Set up filesystem object for usage
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Get folder name to process off the command line, make sure it's valid
If (WScript.Arguments.Count > 0) Then
    strFolder = Wscript.Arguments(0)
    If Not objFSO.FolderExists(strFolder) Then
        WScript.StdErr.WriteLine "Specified folder does not exist."
    End If
    WScript.StdErr.WriteLine "No folder name specified to process."
End If

' Access the folder to process
Set objFolder = objFSO.GetFolder(strFolder)

' Load Excel for conversions
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.DisplayAlerts = False

' Process files
For Each objFile In objFolder.Files
   strPath = objFile.Path
   ' Only convert CSV files
   If LCase(objFSO.GetExtensionName(strPath)) = LCase(strCSV) Then
      ' Load into Excel and save as native Excel file
      Set objWorkbook = objExcel.Workbooks.Open(strPath, False, True)
      objWorkbook.SaveAs Replace(strPath, strCSV, strExcel), cExcel8
      objWorkbook.Close False
      Set objWorkbook = Nothing
   End If

'Wrap up
Set objExcel = Nothing
Set objFSO = Nothing

Open in new window

mcrmgAuthor Commented:
Hi, bill,

Thanks for the script, but it looks like it does not modify the delimiter, or maybe I am not using it correctly. Thx
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.