Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-09-09
2
Medium Priority
?
233 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 2000 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
cPanel is a Unix based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides functionality for administrators, rese…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

670 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