Solved

Batch rename files (specific date format) in windows xp explorer

Posted on 2010-09-09
2
230 Views
Last Modified: 2012-08-13
I have several hundred files that have names that include dates, in either YYYY-MM-DD or YYYYMMDD format.  I need to batch find and replace these dates to convert them to MMDDYYYY.  But also, to move the date to the end of the file name, with a space prior to the date So for instance:

1989-06-19-COMPANY-COMPANY-SPCC GEN INFO.TIF

would be renamed:

COMPANY-COMPANY-SPCC GEN INFO 06191989.TIF


20100809 - Remed - Stantec - HASP for GWM.pdf

would be renamed

- Remed - Stantec - HASP for GWM 08092010.pdf


Thank you in advance,

Anthony
0
Comment
Question by:antimel
[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 Comments
 
LVL 3

Accepted Solution

by:
ia2189 earned 500 total points
ID: 33640439
Be sure to make a backup copy of your files as the below code will delete the original files.  I tested the code given your two examples and it ended with the desired results.

- Copy and paste the below code into Notepad.
- Change the [YOUR FOLDER PATH HERE] to be the location of the folder where your files are stored
- From Notepad, save the document as a .txt file
- Go to where you saved the .txt file and change the extension from .txt to .vbs
- Double-click the .vbs file to run it
- A message box will appear when completed.

Dim fso
Dim oFolder
Dim oFile
Dim sNew
Dim sExt

Set fso = CreateObject("Scripting.FileSystemObject")

Set oFolder = fso.GetFolder("[YOUR FOLDER PATH HERE]")

For Each oFile In oFolder.Files

   If IsNumeric(Mid(oFile.Name, 1, 8)) Then 'Example two in question

      sExt = Right(oFile.Name, 4)

      sNew = LTrim(Mid(oFile.Name, 9))
      sNew = Replace(sNew, sExt, "") & " "
      sNew = sNew & Mid(oFile.Name, 5, 2)
      sNew = sNew & Mid(oFile.Name, 7, 2)
      sNew = sNew & Mid(oFile.Name, 1, 4)
      sNew = sNew & sExt

      oFile.Copy oFolder.Path & "\" & sNew, True
      oFile.Delete True
         
   ElseIf IsNumeric(Mid(oFile.Name, 1, 4)) Then 'Example one in question

      sExt = Right(oFile.Name, 4)

      sNew = LTrim(Mid(oFile.Name, 12))
      sNew = Replace(sNew, sExt, "") & " "
      sNew = sNew & Mid(oFile.Name, 6, 2)
      sNew = sNew & Mid(oFile.Name, 9, 2)
      sNew = sNew & Mid(oFile.Name, 1, 4)
      sNew = sNew & sExt

      oFile.Copy oFolder.Path & "\" & sNew, True
      oFile.Delete True

   End If
   
Next

MsgBox "Process complete!"
0
 
LVL 1

Author Closing Comment

by:antimel
ID: 33641363
That was amazing and will save me so much time.  Thank you so much.

Anthony
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

617 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