Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

txt to csv (vbs)

Posted on 2013-10-30
3
Medium Priority
?
825 Views
Last Modified: 2013-10-30
Hello,
is there any .vbs or .bat (double clicking), that would change the extensions of files in a certain folder (C:\Users\Wassim.QA-DOMAIN\Desktop\Orders Invoices)
from .txt to .csv when the file name starts with
116
1023
10052
7351
1645

from .csv to .txt when the file name starts with
451
4645
7714

Sometimes some of the files do not exist.

Any help is appreciated.
Thanks,
0
Comment
Question by:W.E.B
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 57

Accepted Solution

by:
Bill Prew earned 1000 total points
ID: 39611192
Here's a small BAT file that will do the job, just adjust the folder name near the top.

@echo off

REM Define location of files, and prefixes for file names to rename
set BaseDir=c:\ee\ee28280865\files
set txt2csv=116,1023,10052,7351,1645
set csv2txt=451,4645,7714

REM Move to directory where files are
pushd "%BaseDir%"

REM Rename TXT files to CSV
for %%A in (%txt2csv%) do ren "%%A*.txt" "*.csv" >NUL 2>&1

REM Rename CSV files to TXT
for %%A in (%csv2txt%) do ren "%%A*.csv" "*.txt" >NUL 2>&1

REM Return to original directory
popd

Open in new window

~bp
0
 

Author Closing Comment

by:W.E.B
ID: 39611202
Thank you.
Works like a charm.
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 39611209
Welcome.

~bp
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question