Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Mass rename of files

Posted on 2007-03-19
6
Medium Priority
?
254 Views
Last Modified: 2010-05-18
I have about 3000 files entitled *_copy.mp3, where the * is the song name. I want to rename all these by removing the "_copy" portion of the name.

thisisasong_copy.mp3 would become thisisasong.mp3

Can you suggest an efficient way to do this?

Thanks!
JohnD

0
Comment
Question by:johndarby
[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
  • 3
  • 2
6 Comments
 
LVL 1

Author Comment

by:johndarby
ID: 18754123
This is the VBScript I have thus far...

Dim filesys, file, folderName, folderObj, fileColl, objRegEx, newFile

Set filesys = CreateObject("Scripting.FileSystemObject")

folderName = InputBox("", "Folder Name")

Set folderObj = filesys.GetFolder(folderName)

Set fileColl = folderObj.Files

Set objRegEx = New RegExp
objRegEx.Pattern = "_copy"     ' looking for this

For Each objFile In fileColl
  newFile = objRegEx.Replace(objFile.Name, "")     ' replacing with this
  filesys.MoveFile objFile, folderName & "\" & newFile
Next
0
 
LVL 70

Expert Comment

by:Merete
ID: 18754656
johndarby
*_copy.mp3<< if your files have this name it maybe the results of a chkdsk detecting multiple copies of the same files.
Duplicate Checker is a powerful tool for finding duplicate images, mp3s and any other file types. Using this utility you can organize files on your hard disk or server storage.
http://www.duplicatechecker.com/

HOW TO: Rename Multiple Files in Windows XP with Windows Explorer
http://support.microsoft.com/kb/320167
http://www.codeproject.com/useritems/FileTreeCtrl.asp

File Renaming Tools
http://www.snapfiles.com/Freeware/system/fwfilerename.html

Just ideas
cheers M

0
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 18755217
Taking the script you've started...no regex really needed - use the replace function...

Dim filesys, file, folderName, folderObj, fileColl, objRegEx, newFile
Set filesys = CreateObject("Scripting.FileSystemObject")
folderName = InputBox("", "Folder Name")
'Make sure there's a trailing slash
If Right(folderName, 1) <> "\" Then folderName = folderName & "\"
Set folderObj = filesys.GetFolder(folderName)

For Each file In folderObj.Files
  If InStr(file.Name, "_copy") > 0 Then 'Only process files that have _copy
    filesys.MoveFile file.Path, Replace(file.Path, "_copy", "")
  End If
Next
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:johndarby
ID: 18758726
As per usual, you rock, SB!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18758817
Happy to help - thanx for the grade! :^)
0
 
LVL 1

Author Comment

by:johndarby
ID: 18760922
Sirbounty, what instruction do I add to make the name change recurse through subdirectories?
Thanks!
JohnD
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Have you ever had a hard drive that you can't boot into, but need to change the registry? Here is the solution! This article guides you through accessing and editing a registry of a non-primary drive. To read registry information on a non-prim…
Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

610 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