Solved

txt to csv (vbs)

Posted on 2013-10-30
3
789 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:Wass_QA
  • 2
3 Comments
 
LVL 51

Accepted Solution

by:
Bill Prew earned 250 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:Wass_QA
ID: 39611202
Thank you.
Works like a charm.
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 39611209
Welcome.

~bp
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now