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.

As you can see the file names are very long. If we can strip out the FQDN "" 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?
ZabagaRConnect With a Mentor Commented:
This batch script loops over all .csv files in the folder where the batch file is saved and replaces the partial word "" with an "a" inside the filenames. You can see below you can replace whatever you want by setting 'old' and 'new' values:

@echo off
SET new=a
for /f "tokens=*" %%f in ('dir /b *.csv') do (
  SET newname=%%f
  SET newname=!newname:%old%=%new%!
  move "%%f" "!newname!"
Thomas GrassiSystems AdministratorAuthor Commented:
Worked great

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.