Solved

universal change filename

Posted on 2011-09-21
4
282 Views
Last Modified: 2012-05-12
Hi,

I have 500 pdf, the filename has bunch of "_", some are 9, some have 10.

is there a way to trim 7th "_" and after for all files?  thx
0
Comment
Question by:mcrmg
  • 2
  • 2
4 Comments
 

Author Comment

by:mcrmg
Comment Utility
actually, not the 7th one, should be second one from the right...possible?  thx
0
 
LVL 11

Expert Comment

by:X_layer
Comment Utility
Can you post one filename for example.
0
 

Author Comment

by:mcrmg
Comment Utility
sure


file_123456_dco1_doc_abc_aa_20110919_ABC123456_987_20110919_130000.pdf


to


file_123456_dco1_doc_abc_aa_20110919_ABC123456_987.pdf
0
 
LVL 11

Accepted Solution

by:
X_layer earned 250 total points
Comment Utility
Try this, but please put only few files into c:\temp folder to try script.
Dim fso, sfolder, folder, files, tempfilename, newfilename

Set fso = CreateObject("Scripting.FileSystemObject")
sfolder = "C:\Temp"
Set folder = fso.GetFolder(sfolder)
Set files = folder.Files
  
For each folderIdx In files
	tempfilename = Left(folderIdx.Name, Len(folderIdx.Name) - (Len(folderIdx.Name) - (InStrRev(folderIdx.Name, "_"))) - 1)
	newfilename = Left(tempfilename, Len(tempfilename) - (Len(tempfilename) - (InStrRev(tempfilename, "_"))) - 1)
	fso.MoveFile sfolder & "\" & folderIdx.Name, sfolder & "\" & newfilename & ".pdf"
Next

Open in new window

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

772 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

11 Experts available now in Live!

Get 1:1 Help Now