Renaming thousands of files at once.

This forum is for all Flare related Tips and Tricks.
Have a tip or trick you use while working in Flare? Share it here.

Renaming thousands of files at once.

Postby bhargava on Fri Jan 09, 2015 12:16 am

Hi,

I am working on a project that was imported from Framemaker. The filenames of the .htm files are not in a standard format, so I want to rename and update all links related to that file.
I can use the Rename file and then Update all links, but doing this manually for tens of thousands of files sounds like very time consuming.

Is there anyway to automate this process by writing a program to Rename-file + get related files(using the "Linked from" list in Link Viewer) and update with new file name.
Does Madcap Flare provide APIs that will get the list of Linked-froms for given file? Or an API that does the whole renaming process and updating links on per-file basis?
Please help me with this.

Thanks.
bhargava
Jr. Propeller Head
 
Posts: 3
Joined: Mon Dec 22, 2014 5:38 am

Re: Renaming thousands of files at once.

Postby wclass on Fri Jan 09, 2015 4:35 am

I've used an external tool called FAR to do this sort of thing. Not free but is very useful and very reasonable price.
Have a look at: http://www.helpwaregroup.com/products/far
Margaret Hassall - Melbourne
wclass
Propellus Maximus
 
Posts: 1227
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia

Re: Renaming thousands of files at once.

Postby kwag_myers on Fri Jan 09, 2015 7:11 am

The best I can offer is a two-step process (and please make a backup of the folder first):

First, copy the following code to a NotePad file and save it with a .vbs extension. Be sure to change C:\Users\kwag.myers\Documents\Test to the correct directory. This script creates a log of all files having spaces in the name and changes the space to an underscore.

Code: Select all
Dim sName
Dim fso
Dim fol

Set fso = WScript.CreateObject("Scripting.FileSystemObject")
   
' get current folder
Set fol = fso.GetFolder("C:\Users\kwag.myers\Documents\Test")
' log files with spaces
Set NewFile = fso.CreateTextFile(fol&"\FileList.txt", True)

' go thru each file in the folder
For Each fil In fol.Files
    ' check if the file name contains spaces
    If InStr(1, fil.Name, " ") <> 0 Then
        ' log the file name
        NewFile.WriteLine(fil.Name)
        ' replace with underscore
        sName = Replace(fil.Name, " ", "_")
        ' rename the file
        fil.Name = sName
    End If
Next

WScript.Echo "Completed!"


Then, using the FileList.txt, use my search and replace script here to update all links.
"I'm tryin' to think, but nothin' happens!" - Curly Joe Howard
kwag_myers
Propellus Maximus
 
Posts: 810
Joined: Wed Jul 25, 2012 11:36 am
Location: Ann Arbor, MI


Return to Tips and Tricks

Who is online

Users browsing this forum: No registered users and 1 guest