Solved

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

Posted on 2010-09-09
2
227 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
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dell XPS 1640 Laptop motherboard replacement 31 174
change prefix in multiple files in one folder 11 74
Virtual PC for Windows 10 18 209
windows explorer default details view 10 57
Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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