| 1. |
Solve : Rename nearly 21k files according to XML File? |
|
Answer» Hi Everyone, it looks for music file called AD0013046.wma It was an .mp3 file before! Hi, Sorry yes, MP3 was a mistake, they are all .wma filesThis was difficult because no parent node was shown in the sample XML. So I MADE one up called Music. There was also an error in the original script which has been corrected. Also the rename logic has been added. The script rename the AD files on disk using a combination of the artist and title name. The files are renamed on the disk. If you need to update the ID3 tag info let us know. Sample Test Data: Code: [Select]<?xml version="1.0" encoding="utf-8"?> <Music> <Song Artist="artist here " Title="thesongname here" SearchArtist="artist name" SearchTitle=" title" Styles="70s"> <Audio>13046</Audio> </Song> <Song Artist="Traffic" Title="The Low Spark Of High Heeled Boys" SearchArtist="Traffic" SearchTitle="The Low Spark Of High Heeled Boys" Styles="70s"> <Audio>66666</Audio> </Song> <Song Artist="Beatles" Title="Beatles VI" SearchArtist="Beatles" SearchTitle="Beatles VI" Styles="60s"> <Audio>45678</Audio> </Song> </Music> The is the new script: Code: [Select]Set xmlDoc = CreateObject("Microsoft.XMLDOM") Set fso = CreateObject("Scripting.FileSystemObject") xmlDoc.async = False xmlDoc.load("c:\temp\Songs.xml") Set colNodes = xmlDoc.getElementsByTagName("Music/Song") For Each node In colNodes Set colAttrib = node.attributes artist = colAttrib.getNamedItem("Artist").text title = colAttrib.getNamedItem("Title").text srchArtist = colAttrib.getNamedItem("SearchArtist").text srchTitle = colAttrib.getNamedItem("SearchTitle").text style = colAttrib.getNamedItem("Styles").text filename = "AD" & xmlDoc.getElementsByTagName("Audio").item(i).text & ".wma" WScript.Echo "Artist-" & artist WScript.Echo "Title-" & title WScript.Echo "Srch Artist-" & srchArtist WScript.Echo "Srch Title-" & srchTitle WScript.Echo "Style-" & style WScript.Echo "Filename-" & filename WScript.Echo"--------------------------------------------" Set f = fso.GetFile(filename) f.Name = artist & "-" & title & ".wma" i=i+1 Next Save this into the same folder where the songs and XML file live. Save with a VBS extension and RUN as cscript scriptname.vbs There might be some excessive code in the script. It will not harm anything. Recommend you test this out in a test directory before going live. Testing turned up no errors. Please help (1) i have one xml with lots many tags (2) i have many audio files with random generated number as a name and that name is in XML file (3) please tell me how can i rename those audio files with one of tag details present in xml file. i have to search that audio file as the name of the audio file is present in xml and under that section i will use one of the tag to rename it example - - Gambardella, Matthew XML Developer's Guide Computer 44.95 2000-10-01 An in-depth look at creating applications with XML. - Ralls, Kim Midnight Rain Fantasy 5.95 2000-12-16 A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world. - Corets, Eva Maeve Ascendant Fantasy 5.95 2000-11-17 After the collapse of a nanotechnology society in England, the young survivors lay the foundation for a new society. - Corets, Eva Oberon's Legacy Fantasy 5.95 2001-03-10 In post-apocalypse England, the mysterious agent known only as Oberon helps to create a new life for the inhabitants of London. Sequel to Maeve Ascendant. - Corets, Eva The Sundered Grail Fantasy 5.95 2001-09-10 The two daughters of Maeve, half-sisters, battle one another for control of England. Sequel to Oberon's Legacy. - Randall, Cynthia LOVER Birds Romance 4.95 2000-09-02 When Carla meets Paul at an ornithology conference, tempers fly as feathers get ruffled. - Thurman, Paula Splish Splash Romance 4.95 2000-11-02 A deep sea diver finds true love twenty thousand leagues beneath the sea. - Knorr, Stefan Creepy Crawlies Horror 4.95 2000-12-06 An anthology of horror stories about roaches, centipedes, scorpions and other insects. - Kress, Peter Paradox Lost Science Fiction 6.95 2000-11-02 After an inadvertant trip through a Heisenberg Uncertainty Device, James Salway discovers the problems of being quantum. - O'Brien, Tim Microsoft .NET: The Programming Bible Computer 36.95 2000-12-09 Microsoft's .NET initiative is explored in detail in this deep programmer's reference. - O'Brien, Tim MSXML3: A Comprehensive Guide Computer 36.95 2000-12-01 The Microsoft MSXML3 parser is covered in detail, with attention to XML DOM interfaces, XSLT processing, SAX and more. - Galos, Mike Visual Studio 7: A Comprehensive Guide Computer 49.95 2001-04-16 Microsoft Visual Studio 7 is explored in depth, looking at how Visual Basic, Visual C++, C#, and ASP+ are integrated into a comprehensive development environment. (a)audio file name is >> bk101.mov which is defined as a book id in xml file , now i want to change it to computer.wav (which is in genre tag under book id tag of bk101) thank you You revived a 4 year old thread. You need to start your own thread. |
|