Script Helped needed

Need to reduce the number of characters in a file that was generated by a program that I do not have the code for.

The program generates 30 files with the extension of .csv  (csv2 format)

I have a script that takes all the 30 files and merges them into one spreadsheet as a separate sheet. My problem is that Excel has a 31 character limit on sheet names.

The program generates file names as such.

soft_abc.network.mydomain.com-Computer01_20130905_195826.csv
soft_abc.network.mydomain.com-Computer02_20130905_195838.csv
hard_abc.network.mydomain.com-Computer01_20130905_195910.csv
hard_abc.network.mydomain.com-Computer02_20130905_195950.csv
other_abc.network.mydomain.com-Computer01_20130905_195735.csv
other_abc.network.mydomain.com-Computer02_20130905_195750.csv
overview_abc.network.mydomain.com-Computer01_20130905_195610.csv
overview_abc.network.mydomain.com-Computer02_20130905_195640.csv
overview_devices-192.168.1.3_20130905_195540.csv
overview_devices-192.168.1.40_20130905_195550.csv


As you can see the file names are very long. If we can strip out the FQDN "abc.network.mydomain.com" that would reduce the name enough.
Only other one is the overview_devices I needed to remove the word devices and the time at the end. Can that be scripted also?

This needs to run on a Windows 2003 Server.

I have been doing this manually but I would like to script this so my batch job can be scheduled and run unattended


Thanks as always for your help.
LVL 23
Thomas GrassiSystems AdministratorAsked:
Who is Participating?
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.

ZabagaRCommented:
This batch script loops over all .csv files in the folder where the batch file is saved and replaces the partial word "abc.network.mydomain.com" with an "a" inside the filenames. You can see below you can replace whatever you want by setting 'old' and 'new' values:

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
SET old=abc.network.mydomain.com
SET new=a
for /f "tokens=*" %%f in ('dir /b *.csv') do (
  SET newname=%%f
  SET newname=!newname:%old%=%new%!
  move "%%f" "!newname!"
)
0

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
Thomas GrassiSystems AdministratorAuthor Commented:
Worked great

need to modify for other files but got the help I needed

Thanks
0
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
VB Script

From novice to tech pro — start learning today.