1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

help please-batch file renamer-???

Discussion in 'Business Applications' started by soulalways, Jan 24, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. soulalways

    soulalways Thread Starter

    Joined:
    Jan 24, 2011
    Messages:
    6
    hi guys,
    can someone please give advice on the following.
    i have about 250 mp3 files in a folder.
    e.g. of a song is as follows-artist-title

    e.g.
    norma jenkins-can you imagine that

    i want to add the initial of the folder(s) with all these mp3,s in it

    to

    e.g
    norma jenkins-can you imagine that-s

    first,have i got the right program to do this?
    second,if so,how do i do it please???

    would appreciate some help.

    many thanks(y)
     
  2. Ent

    Ent Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,467
    First Name:
    Josiah
    No doubt one of the batch experts will be around shortly to show how it can be done with that language. However since batch isn't very good at text manipulation I'll go for a VBS script instead.

    Copy and Paste the following into Notepad. Click Save as, and save it as MP3Rename.vbs
    The most important part is that .vbs at the end.
    Move that file into any folder that you want to process, it will get the initial of that folder's name and append it to the file name. It will pop up a message once done.

    Please test it on a copy of a few files before letting it loose on your main pack of files! It is entirely possible that I've misunderstood what you want.

    Code:
    Dim CFN 'Current Folder Name
    Dim CFNr ' Current Folder name without path
    Dim CFI 'Current Folder Initial
    Dim CF ' Current Folder, Object
    Dim FileNames ' File names in current folder. '
    Dim FN ' Name of the file. '
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    ScriptPath = Wscript.ScriptFullName ' Get the name of the current folder
    Set objScriptPath = objFSO.GetFile(ScriptPath)
    CFN = objFSO.GetParentFolderName(objscriptPath)
    
    Set objFolderPath = objFSO.getFolder(CFN) ' Gets the initial of the current folder
    CFNr = mid(CFN, len(objFSO.GetParentFolderName(objFolderPath)) + 2)
    CFI = left(CFNr,1)
    
    Set CF = objFSO.GetFolder(CFN)
    Set files = CF.Files
    For each objFile In files
      FN = objFile.name
      If Lcase(right(FN,4)) = ".mp3" then
        objFSO.MoveFile CFN & "\" & FN, CFN & "\" & left(FN,len(FN)-4) & "-" & CFI & ".mp3"
      End if 
    Next
    msgbox "Rename Complete"
    
     
  3. soulalways

    soulalways Thread Starter

    Joined:
    Jan 24, 2011
    Messages:
    6
    hi,
    thanks for the reply,did everything you instructed me to do,but nothing happened when i dropped the file into a test folder???
     
  4. Ent

    Ent Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,467
    First Name:
    Josiah
    My bad, I forgot to mention the last step. You have to double click the script file to run it, much as you would with any other program.
     
  5. soulalways

    soulalways Thread Starter

    Joined:
    Jan 24, 2011
    Messages:
    6
    i did that but a "windows script host " box appeared with

    script drive\mp3rename.vbs
    line 27
    char 2
    error invalid character
    code 800ao408
    source Microsoft VBScript compilation error
     
  6. Ent

    Ent Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,467
    First Name:
    Josiah
    That is strange, there is no line 27 to that script, and it works fine when tested on my computer.
    I'll upload a Zip File with the script in it just in case there's something wrong in copying it over.
     

    Attached Files:

  7. soulalways

    soulalways Thread Starter

    Joined:
    Jan 24, 2011
    Messages:
    6
    unzipped & dropped the file into folder ,same box appeared ?
     
  8. coachdan32

    coachdan32

    Joined:
    Nov 13, 2003
    Messages:
    1,021
    Try Tag-It
     
  9. soulalways

    soulalways Thread Starter

    Joined:
    Jan 24, 2011
    Messages:
    6
    Hi ENT,
    many thanks for your advice,but i have just found a soloution in a little proggy called bulk rename utility.
    took me 10 seconds to sort this out!
    here,s me thinking im a total dummy!
    LOL!

    cheers

    alex
     
  10. Ent

    Ent Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,467
    First Name:
    Josiah
    I'm glad you have it sorted out. I'm still not sure what could go wrong with that script, but I guess it doesn't matter any more.

    As the original poster you and only you can click the "mark solved" button at the top of the thread. This will alert others with the same issue that a possible fix can be found here. Likewise it will help to ensure that our volunteers focus on issues which still lack a solution instead of possibly wasting time here.
     
  11. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/976694

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice