Script to rename multiple files

I have about 30k image files on my pc in 1 dir C:\TEMP1\ for example. These files all have to be renamed to a specific unique name. Aside from these files I also have an xml file that contains properties for these files, document title, document id for example.
The xml file also contains the path and file name of the image files. I need a script that can read the xml file, find the tag <ExternalRef> and then go out to C:\TEMP1\ and rename that file according to other xml tags such as document title and document
id. I have 1 xml file for all 30k images. I dont have any scripting experience and was looking for some help.
This is what the xml file looks like: So I need to find <ExternalRef>file://C:\TEMP1\000E57BC.TIF</ExternalRef> and rename that file to <DocumentTitle>Probate Order-SO</DocumentTitle> _<ABC_DocumentID>APO24L977</ABC_DocumentID>...etc
- <ABC_TitleDocument>
- <ABC_TitleDocumentProperties>
  <ObjectType>1</ObjectType>
  <Creator>Administrator</Creator>
  <DateCreated>2013-10-07T16:45:27.237Z</DateCreated>
  <LastModifier>Administrator</LastModifier>
  <DateLastModified>2013-10-07T16:45:27.237Z</DateLastModified>
  <Id>6132c424-007b-4ef9-9c07-2b8171b83357</Id>
  <Name>Probate Order-SO</Name>
  <SecurityPolicy />
  <SecurityParent />
  <IsFrozenVersion>0</IsFrozenVersion>
- <VersionSeries>
- <ObjectRef>
  <ObjectId>1be7c26c-89d2-40bf-afeb-a081714e470a7</ObjectId>
  <ClassId>01a3a8c8-7aec-11d1-a31b-a0020af9fbb1c</ClassId>
  </ObjectRef>
  </VersionSeries>
  <MajorVersionNumber>1</MajorVersionNumber>
  <MinorVersionNumber>0</MinorVersionNumber>
  <VersionStatus>1</VersionStatus>
- <ContentElements>
- <ContentTransfer>
  <ObjectType>1038</ObjectType>
  <ContentType>image/tiff</ContentType>
  <RetrievalName>000E57ABC.TIF</RetrievalName>
  <ExternalRef>file://C:\TEMP1\000E57BC.TIF</ExternalRef>
  </ContentTransfer>
  </ContentElements>
  <MimeType>image/tiff</MimeType>
  <DocumentLifecyclePolicy />
  <DocumentTitle>Probate Order-SO</DocumentTitle>
  <SourceDocument />
  <OwnerDocument />
  <PublicationInfo />
  <IgnoreRedirect />
  <EntryTemplateObjectStoreName />
  <EntryTemplateLaunchedWorkflowNumber />
  <EntryTemplateId />
  <ABC_Area>P</ABC_Area>
  <ABC_DocumentCategory>Title</ABC_DocumentCategory>
  <ABC_DocumentClass>11</ABC_DocumentClass>
  <ABC_DocumentID>APO24L977</ABC_DocumentID>
  <ABC_LandArea>151</ABC_LandArea>
  <ABC_ScanDate>2013-10-07T05:00:00Z</ABC_ScanDate>
  <ABC_ScanOperator>Administrator</ABC_ScanOperator>
  <ABC_ScanWorkstationID>SCN04:Sess 3</ABC_ScanWorkstationID>
  <ABC_Agency>03</ABC_Agency>
  <ABC_DocumentType>ABC</ABC_DocumentType>
  <ABC_LTRO>P</ABC_LTRO>
  <ABC_KofaxID>{DA701CAD-5CB2-444e-9ABBB-47CF0B2FD801}</ABC_KofaxID>
  <ABC_DocumentCount>11</ABC_DocumentCount>
  <ABC_Recordable>1</ABC_Recordable>
  <ABC_BatchType>FOLLOW-UP</ABC_BatchType>
  <ABC_EStamped>0</ABC_EStamped>
  <ABC_RecordationState>PENDING</ABC_RecordationState>
  <ABC_FileName />
  <ABC_FolderName />
  <ABC_BatchName>10/7/2013 8:25:26 AM</ABC_BatchName>
  <ABC_RecordDate>11/19/2004</ABC_RecordDate>
  <ABC_DocumentDate>1977-03-30T05:00:00Z</ABC_DocumentDate>
  <ABC_ConveyanceType>SO</ABC_ConveyanceType>
  </ABC_TitleDocumentProperties>
  </ABC_TitleDocument>

I'm still quite new to this, but I think this would do the trick based on what you've supplied, note the -whatif so it doesn't screw up if the output isn't quite what you want.
[xml]$fileinfo = Get-Content -Path .\fileinfo.xml
foreach ($doc in $fileinfo.ABC_TitleDocument) {
$filepath = $doc.ABC_TitleDocumentProperties.ContentElements.ContentTransfer.ExternalRef -creplace "file://",""
$fileext = (Get-Item -Path $filepath).Extension
$newfilepath = "$($doc.ABC_TitleDocumentProperties.DocumentTitle)_$($doc.ABC_TitleDocumentProperties.ABC_DocumentID)$fileext"
Rename-Item -Path $filepath -NewName $newfilepath -WhatIf

Similar Messages

  • Batch Rename Multiple files with different names

    Hi,
    Is there any way to batch rename multiple files with individual names? I.e
    IMG_123 changed to  RSP45AS
    IMG_124 changed to MOL157A
    IMG_125 changed to AGKH135
    IMG_126 changed to MNOLH13
    IMG_127 changed to ASFBLUG
    Etc.
    Are they any programs or scripts or plug ins that would do that job?
    Thanks

    HI there Onemorewave,
    It looks like there is a batch remname feature included in OS X 10.10 Yosimte if you are planing on updating. 
    Rename files, folders, and disks - Mac Help
    Rename multiple items
    Select the items, then Control-click one of them.
    In the shortcut menu, select Rename Items.
    In the pop-up menu below Rename Folder Items, choose to replace text in the names, add text to the names, or change the name format.
    Replace text: Enter the text you want to remove in the Find field, then enter the text you want to add in the “Replace with” field.
    Add text: Enter the text to you want to add in the field, then choose to add the text before or after the current name.
    Format: Choose a name format for the files, then choose to put the index, counter, or date before or after the name. Enter a name in the Custom Format field, then enter the number you want to start with.
    Click Rename.
    Note: To batch rename, you would want to choose the "Format" option.
    -Griff W

  • How do i rename multiple files at the same time on a MAC?

    I have been a mac user since 4 years now yet i cannot figure out how to rename multiple files in mac. In Pc i used to slect all and rename one e:g "ab.jpg" and the restwould be "ab (1).jpg" automatically. but in the mac its way too hard to do this on the automator. ..
    please advise asap!
    ~haniah

    You can do it with Automator.
    http://www.automator.us/examples-01.html
    Or with a utilities like these:
    http://www.publicspace.net/ABetterFinderRename/
    http://renamer4mac.com/
    You can also do it using the Terminal command line.
    Matt

  • Renaming multiple files using automator.

    hello. i am renaming multiple files using automator. now when i import the images they are in sequential order like dscn001, dscn002 etc... i want to rename it to 001 my pic, 002 my pic, etc...
    i am choosing the sequential renaming option. after importing the pics to automator i see to it that i sort them by name so that the new names i provide are in the order of the actual file names ie. 001mypic = dscn001, 002mypic = dscn002, etc..
    however, it seems that inspite of sorting then my name they are being renamed randomly. what should i do. this is distrubing the cronological order of the pics.
    thanks in advance
    Neerav

    Well, whenever I rename in sequential order (presorted or otherwise), that is exactly what happens, so I am not sure what is causing your particular problem. If you look at the results of sorting before the rename, you should see that the items are renamed in that order - although the way that they are sorted after the rename may be different. You can easily see this sorting by just adding a prefix/suffix and looking at the differences in how the lists are sorted (sorting by name (numerically) may give you different results). Check out this Apple document to see if this is what is happening.

  • How can I rename multiple files simultaneously

    I'm new to Macs and I'm looking for a way to rename multiple files simultaneously. These are photos from my SD card that I wish to give the same name but increment the name by 1 at the end of the filename.

    A Better Finder Rename is perfect for this.   I use it all the time to rename image files.
    There is also a companion app called A Better Finder Attributes that is also useful for image files.

  • How do you rename multiple files at the same time

    how do you rename multiple photo files with a name at the same time?

    This would be an excellent use of Automator. Here is a link to some instructions on how to do this using Automator.
    http://www.youtube.com/watch?v=Ie6zGxo2D-o
    If you don't like that then Google "Renmame multiple files Automator" and you will find many tutorials available.

  • Using a script to rename a file from the file info cart Cut Num (ID)??

    Hi,
    Can any of you guys tell me if its poss to do a script to rename a wav with the file info, cart, Cut Num ID field....??? (Cart chunks)
    Example file at the moment is called {C5E5F0FE-57D9-4A9A-8DA1-58D1AE7017FD}.wav and I want to grab the info out of the File info, cart section, under Cut Num (ID) which has 9558 in it and rename the file so it is now 9558.wav when it saves or just renames it.I also then want to run the script as i have 6000 plus wav,s to do this too.
    Thanks for any info.
    Glen

    >Can any of you guys tell me if its poss to do a script to rename a wav with the file info, cart, Cut Num ID field....??? (Cart chunks)
    No, scripts in Audition won't let you do this at all. In fact, Audition's scripting function really isn't very file-friendly, relating pretty much just to basic Audition functionality. And there's no way that an Audition script would let you rename a file anyway - they the closest they get to handling any file-related functions is that you can open a designated noise reduction profile - but that's about it.
    There's one place that I know of where you might find a utility to do what you want -
    here (try WidgetPro).

  • Renaming multiple files

    I just switched from a pc laptop to a mbp i7. I'd like to rename multiple jpg files but can't even figure out how to rename ONE file, let alone multiple files. Example: xxxxx.jpg to trip.jpg where all the files will be named "trip" and numbered. Make sense? Pretty easy to do in windows, so I can't imagine it would be difficult to do with this new baby. Can anyone help?

    PuppyDogMom wrote:
    Does this mean that after getting this very expensive computer that I have to spend another $20 to get something that will help me re-name batch files? Seriously?
    A great tip for a new Mac user is that when you need new software of any kind, you can go to a site like macupdate.com and see if there are any free programs that do it. I know about "A Better Finder Renamer" but there are cheaper or free alternatives.

  • Looping in Maxl Script - To load multiple files

    Hi,
    I am using Essbase 11.1.2 on UNIX.
    I have maxl script which will load 20 to 30 extraction file. Number is inconsistent. Extraction files will grow each month. Extraction files are with same name with the suffix _1,_2...(2 Gb thing). My previous script was hard coded to load file by file to load up to 50 files. I am trying to remove these hard coded lines, and try to loop the “load” statement. I have tried several ways using while loop in shell to call maxl /msh , but no luck. Any ideas?
    Thanks

    A very similar question was asked recently (but for Windows): Re: Maxl to import datafolders
    What have you tried? Maybe someone here can show you what's wrong with your script.
    The approach I usually take with this type of problem is to write a script that dynamically builds one single MaxL script with the appropriate number of files, rather than calling MaxL multiple times.
    I am generally too ashamed to share my Unix scripts, but at it's most basic, non-error-trapped, probably-inadvisable-and-full-of-holes-for-all-kinds-of-reasons, you could include something like this to build your load script:
    ls filename*.txt | awk {'print "import database etc... "$1" ...on error etc;"'} > scriptname.mshSince you can nest MaxL scripts, you can then reference scriptname.msh from a static 'master' script which handles login / spool on / spool off / logout as appropriate. See http://download.oracle.com/docs/cd/E17236_01/epm.1112/esb_tech_ref/maxl_commands_nesting.html or Cameron's 2009 K'scope presentation: http://odtug.com/apex/f?p=500:575:526121996615242::NO::P575_CONTENT_ID:4605

  • Automator or Apple Script To Move Multiple Files to Multiple Folders

    I was just wondering, is there any sort of automator workflow or maybe apple script that will allow me to automate the following:
    I have a folder named SCANS containing multiple different files that need to go to multiple different folders.
    So Say I have:
    SCANS
    and in this folder I have ten files named A,B,C,D,E,F,G,H,I,J and I want each of these files to be moved to different folders eg.
    A I want to go to folder 1
    B I want to go to folder 2
    C I want to go to folder 3 etc etc.
    Anyone know if there is a way of doing this please?
    I have tried a workflow where I find finder items in the Scans folder and move to another but that only seems to work for one file.  When I add more it does not seem to work.
    Any help/guidance would be appreciated.
    Thank you!

    Hi Niel,
    Not quite what I wanted because I missed some information from my question....
    What I actually want is to search for files containing certain text in the name and if positive to then move that file to the specified folders.
    Cheers.

  • Script for emailing multiple file types?

    Is there a script that will allow me to place a button on a form, that when clicked, will email the completed form in PDF format as well as in csv, or xml format?
    Thanks!

    Wow, thanks. That was extremely helpful, but I have a couple questions.
    First, is there a way to make it print to CUPS without opening the default application for the particular file first? For example, I used a .docx file, and it had to open microsoft word to send the job the print. This makers it very unpredictable to decide how much time the automator application will need to pause. If that file were for example, and adobe illustrator file, it would take an incredible amount of time just for illustrator to open. I don't really anticipate needing to do this a whole lot with anything other than text files and standard image types, but is that the only way for those other files to print? I figured that since OS 10.6 can do a quick look preview on just about any file type I use, that the OS would be able to do this without the application actually opening, but it seems not to be the case. Just wondering.
    The other issue is the only real problem, and it's one that I have had whenever I use automator to make PDFs. It always duplicates the job. So, I am getting a combined pdf, but it has the same file in there 2 or even 3 times.
    In automator, I used:
    get selected finder items
    then
    print finder items
    I have verified that it is printing everything multiple times because I see them going into the CUPS folder twice. Then, the final PDF sometimes even has the same doc or image in it 3 times. I have always had this problem with automator and PDFs, any idea how to solve that?
    Other than that duplication issue, this seems like it will work perfectly! Thanks for the reply here!

  • Script for renaming postscript files

    I need a script that will rename a postscript file at the time of printing. Ideally, after you hit the print button, a field would appear for you to enter the new name of the postscript file prior to sending it on to the printer. After you entered text, you hit enter again and the file goes to the printer for printing. The print log would show the new name. If anyone knows how to do this, I would appreciate your assistance. I could probably get you some cash.
    Thanks,
    Rich

    This forum is for scripting questions rather than script requests.
    Please start by reading the following:
    Posting guidelines
    Handy tips for posting to this forum
    How to ask questions in a technical forum
    Rubber duck problem solving
    How to write a bad forum post
    Help Vampires: A Spotter's Guide
    -- Bill Stewart [Bill_Stewart]

  • Apple Script to rename single files in folders

    Hey guys, I am trying to write a script to automatically rename a lot of files.  Here is the situtation:
    I have a MainFolder with many SubFolders inside.  Inside each SubFolder is 1 word document.  Is there a way to write a script that automatically renames each of of those word documents to its folder's name.  Example.
    BEFORE:
                      -SubFolder1 - 1.doc
                      -SubFolder2 - 1.doc
    -MainFolder -SubFolder3 - 1.doc
                      -SubFolder3 - 1.doc
    AFTER:
                      -SubFolder1 - SubFolder1.doc
                      -SubFolder2 - SubFolder2.doc
    -MainFolder -SubFolder3 - SubFolder3.doc
                      -SubFolder3 - SubFolder4.doc
    Thanks.

    The following script should do what you are asking for:
    set mainFolder to choose folder
    tell application "Finder"
        repeat with thisFolder in (get folders of mainFolder)
            try
                set name of (file 1 of thisFolder whose name extension is "doc") to (name of thisFolder & ".doc")
            end try
        end repeat
    end tell
    If there's just one file in each subfolder (wich is not exactly the same as “one Word document”), you could remove the “whose name extension is "doc"” filter.

  • How do I rename multiple files at same time?

    I'm new to mac...after 20 years of PC I've decided to join Mac, but I'm having trouble with something that was pretty easy on Windows.
    When I upload photos (or any kind of files) to my Mac, and I want all of the files to have the same name (with sequence number to indentify), how should I do?
    For example, I want to rename my vacation pictures to vacation1, vacation2 etcc..but of course I don't want to do one-by one...
    regards

    Hello and Welcome to Apple Discussions, 
    Go to Macintosh HD > Applications > Utilities > Automator.
    First select Library > Get Specified Finder Items.
    Click to enlarge.
    Then choose Action > Rename Finder Items.
    This will rename all the selected files to vacation-nn.jpg etc.
    By clicking the "Media" button at the top you can darg and drop media from iPhoto etc into the Finder items list.
    Hope that helps.
    mrtotes
    Message was edited by: mrtotes

  • How can I rename multiple files without Automator?

    Is there a way to rename a large number of files i.e. "file, file(2) file(3)" without using Automator? In Windows you can just right-click and rename any number of selected files.

    Oh, I heartily agree. I bought it back at version 1.0, but not everyone around here is willing to spend money. The one I suggested that's freeware is a pretty good tool especially for casual sorts of needs. You may want to take a look at it. Not that it replaces ABFR.

Maybe you are looking for

  • Bold or Italics no longer works in Mail

    When composing a message in Mail, using font style shortcuts no longer work. I've tried everything! For example, in the text of my email message, I select the word(s) that I want to bold, I press Cmd+B and it does nothing to the text. The font stays

  • PR table/Report

    Hi all, IS there any table/report which lists out the Planned orders and the converter Purchase requisitions from planned orders? I want a report/table which lists out Purchase requisitions and related Planned orders. Thanks, Avani.

  • Audio only, green and purple screens on quicktime on pc

    audio only,green and purple screens on quicktime on my pc

  • Linking Transactions

    Hi My requirement is to link transactions to new transaction in IC web client via business context. Can some one tell me is that achievable via some standard functionality or do we need developement for that. Regards Ram

  • Help: WRT54GL v1.1 keeps loosing my isp settings

    Hello, Having trouble right out of the box with the above mentioned router with the latest firmware 4.3.12: I can setup my settings ok - isp with DHCP + MAC clone and get the internet (wired and wireless) to work fine but once very often the router g