Renaming From A Text File

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Renaming From A Text File

Postby Stefan » Thu Jun 18, 2015 2:56 pm

Collection of my "Renaming From A Text File" examples.

------------------------------------------------------------------------------
renaming avi files to match srt files...
Postby sampah » 14 Dec 2010, 21:29
hi, im new here, sorry if this not the right section...
here's the thing, i already rename my batch of subtitle files with the episode number, title and all...
how can i rename my video files to match those subtitle files, accordingly using BRU...
thanks...
-----------------------------------------------------------------------------
Re: renaming avi files to match srt files...
Postby Stefan » 12 Feb 2011, 20:51

For the challenge "Rename AVI files (old name) like SRT files (new name)"

Read the help about "Renaming From A Text File"
To use this facility, create a text file in for the correct format, for example:

Track001.mp3|Headlong.mp3
Track002.mp3|Rushes.mp3
TRACK003.mp3|AnywhereIs.mp3

As you see, there is one entry per line.

Next, click the Import option on the File menu and load your file. If the file is valid then you will see the "new name"
column reflecting the contents of the text file.






The idea of this post is to use excel to create such an text file.

Generally spoken:
having the old name in one column (A1), and the new name in an another (B1),
then merging that two columns and add an pipe-symbol "|" as delimiter.
The basic syntax in excel therefor is in column (C1) '= A1 & "|" & B1'
Then use the excel options to copy that formula down all lines.
Code: Select all
         A         B              C                    D          E              F
1     old1      new1        old1|new1
2     old2      new2        old2|new2
3     old3      new3       = A3 & "|" & B3
4     old4      new4     
5     old5      new5     
6     old6      new6     
7
8







Please read an step-by-step explanation for the above challenge, for other issues you may skip some steps.
(EDIT: see the link at the end to see an picture how this looks in excel)


1)
Use
Selection(12) *.avi
to see *.AVI files only


2.)
select All and use context menu > copy to clipboard Name + Ext


3.)
Open Excel and paste this list to column A
Code: Select all
A
AVI name.avi
AVI name.avi
AVI name.avi



4.)
In Excel column B cell 1 write an pipe symbol |
and use Excel to copy it in all cells down the B column
Code: Select all
A               B
AVI name.avi   |
AVI name.avi   |
AVI name.avi   |



5.)
In BRU use
Selection(12) *.srt
to see *.SRT files only

6.)
select All and use context menu > copy to clipboard Name (without Ext)

7.)
paste this list in Excel column C
Code: Select all
A               B   C
AVI name.avi   |   SRTname
AVI name.avi   |   SRTname
AVI name.avi   |   SRTname


8.)
In Excel write .avi into column D and paste it down the column
Code: Select all
A               B   C                       D   
AVI name.avi   |   SRTname     .avi
AVI name.avi   |   SRTname     .avi
AVI name.avi   |   SRTname



9.)
In Excel write this command into column E and paste it down the column
Code: Select all
A               B   C                    D          E
AVI name.avi   |   SRTname     .avi      =A1&B1&C1&D2
AVI name.avi   |   SRTname     .avi      =A2&B2&C2&D2
AVI name.avi   |   SRTname


to get
Code: Select all
A               B   C             D      E
AVI name.avi   |   SRTname    .avi  AVI name.avi|SRTname.avi
AVI name.avi   |   SRTname    .avi  AVI name.avi|SRTname.avi
AVI name.avi   |   SRTname



10.)
select the E column and paste this as text to an text file:
Code: Select all
AVI name.avi|SRTname.avi
AVI name.avi|SRTname.avi
AVI name.avi|SRTname.avi
AVI name.avi|SRTname.avi



11.)
In BRU use the "Renaming From A Text File" feature.

Code: Select all
        1. Select the folder which contains the objects you wish to rename.
        2. Select the files you wish to process (use CTRL or SHIFT to select multiple files).
        3.  Enter the renaming criteria.
             Here, click the Import option on the File menu and load your file.
             If the file is valid then you will see the "new name" column reflecting the contents of the text file.
        4. Hit the Rename button. (This button is not enabled unless you have selected one or more files/folders to rename!)


HTH? :D
Puhh, i hope i didn't mixed something up! avi, srt,,,srt,avi, excel, avi,srt,... ;-)



BTW:
we can also do this with Excel without all this steps between, just enter this as command:
= A1 & "|" & C1 & ".avi"





EDIT:
i have found an web side about Excel to help you using it: http://www.mrexcel.com/articles/function-to-merge-two-columns.php
IF that side is down, please find an picture of it there >>> http://forentmp.lima-city.de/BRU_Excel_Merge2Columns-c16.png
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Renaming From A Text File -post 2

Postby Stefan » Thu Jun 18, 2015 3:01 pm

EDIT:
To join just two lists together, e.g. two directory listings,
i have wrote an little JavaScript to do this.
It's written with EmEditor, but can be adopted i think for others too.
http://www.emeditor.com/modules/newbb/viewtopic.php?topic_id=2091&post_id=6771&order=0&viewmode=flat&pid=0&forum=19#forumpost6771

Code: Select all
// Paste/Merge/Join two list together side-by-side.
// (see examples) Writes result to new document.
//
// Works like one feature of PASTE.exe
//  paste is a Unix command line utility which
//  is used to join files horizontally (parallel merging)
//  by outputting lines consisting of the sequentially
//  corresponding lines of each file specified, [...]
//  It is effectively the horizontal equivalent to the
//  utility cat command which operates on the vertical
//  plane of two or more files.



-----------------------------------------------------
EDIT:

Utilize DOS:

To get a list of your file name, you can utilize DOS.

Open a DOS-Box via Start > Run > cmd
or on Win7 hold Shift-key and right click a folder and chose "Open command prompt here"

Be sure to be in the right folder, then type
"Dir /b > _FileList.txt"
or
"Dir /b *.jpg > _JPGs_FileList.txt"


-----------------------------------------------------
EDIT:

Utilize PowerShell:

#//Get the file name:

#browse to folder with files to become renamed, open PoSh console, and execute
Code: Select all
dir | ForEach{if(!$_.PSisContainer){ $_.Name }} >> oldnames.txt


#browse to folder with files with wanted names, open PoSh console, and execute
Code: Select all
dir | ForEach{if(!$_.PSisContainer){ $_.Name }} >> newnames.txt

#or skip this step, if you have these files in a text file already.



#// Create the list for the Bulk Rename Utility "Renaming From A Text File" method:

#be sure to have both list files together in one folder
Code: Select all
$old=(gc oldnames.txt)
$new=(gc newnames.txt)
$iteration= $old.count -1
$List=""
0..$iteration | ForEach{ $List += ($old[$_] + "|" + $new[$_] + "`r`n")}
$List
$List > List.txt


Now use this List.txt for BRUs "Renaming From A Text File" method!



Find me: Rename from a list "Renaming From A Text File" renaming pairs rename textfile textlist excel sheet
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Renaming From A Text File - post 3

Postby Stefan » Thu Jun 18, 2015 3:03 pm

Group w/ same numbers, different letter
Post by awakeimages » 11 Jun 2015, 05:54
Hi - I'm hoping this isn't something easy that I've missed... Thanks in advance for the help.

Original files:

Image_1
Image_2
Image_3
Image_4
Image_5

I want:

Image_1a
Image_1b
Image_1c
Image_2a
Image_2b
...etc.

--------------------------------------------------------------------

Re: Group w/ same numbers, different letter
Post by Stefan » 11 Jun 2015, 09:44

Only with a little work around via a script or a spreadsheet as Excel or Spread32
to create a OldName|NewName list for BRUs "Renaming From A Text File" feature:

In Excel:

Column A (your original file names
image A_1
image Vac_2
imaging_3
image Test_4
image Bird_5



Column C (drop trailing "_1")
=LEFT(A1;LEN(A1)-2)
<copy the above formula down the rows>

Results in:
image A
image Vac
imaging
image Test
image Bird


Column E (create 1,1,1,2,2,2,3,3,3,4,4,4,... sequence)
1
1
1
=G1+1
=G2+1
=G3+1

<copy the above three formula down the rows>

Results in:
1
1
1
2
2
2
3
3
3
4
4
4
5
5
5



Column H (create a,b,c,a,b,c,a,b,c,... sequence)
a
b
c

<copy the above three cells down the rows>

Results in:
a
b
c
a
b
c
a
b
c
a
b
c
a
b
c


Column J (Join all together)
=A1&".jpg"&"|"&C1&"_"&G1&H1&".jpg"
<copy the above formula down the rows>

Results in:
image A_1.jpg|image A_1a.jpg
image Vac_2.jpg|image Vac_1b.jpg
imaging_3.jpg|imaging_1c.jpg
image Test_4.jpg|image Test_2a.jpg
image Bird_5.jpg|image Bird_2b.jpg



Now Copy the Column J and save as Text file for BRUs "Renaming From A Text File" feature:


In BRU use the "Renaming From A Text File" feature.

Code: Select all
            1. Select the folder which contains the objects you wish to rename.
            2. Select the files you wish to process (use CTRL or SHIFT to select multiple files).
            3.  Enter the renaming criteria.
                 Here, click the Import option on the File menu and load your file.
                 If the file is valid then you will see the "new name" column reflecting the contents of the text file.
            4. Hit the Rename button. (This button is not enabled unless you have selected one or more files/folders to rename!)


 
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Renaming From A Text File - post 4

Postby Stefan » Thu Jun 18, 2015 3:21 pm

Simple Excel Example

-----------------------------------------------------------------
Rename files to a specific list of names?
Postby Daisuk » 18 Jun 2015, 12:59
I have a device that reads wave files. It need the files to be named very specific names to be able to read them.
P1
P2
p3
P4
P5
P6
P7
P8
P9
PA
PB
PC

... etc

-----------------------------------------------------------------

First create a list of current names too:

Open a DOS-Box via Start > Run > cmd
or on Win7 hold Shift-key and right click a folder and chose "Open command prompt here"

Be sure to be in the right folder, then type
"Dir /b > FileList.txt"

Now FileList.txt contains (for example) your current file names:
Code: Select all
alarm_01.wav
bird07.wav
buzzer.wav
chimes_01.wav
egg_timer.wav



----------------------------------
Open a spreadsheet like Excel or Spread32 and paste that list to column A
Code: Select all
alarm_01.wav
bird07.wav
buzzer.wav
chimes_01.wav
egg_timer.wav



----------------------------------
Now paste your list of new names into Column B, you have now:
Code: Select all
alarm_01.wav       P1.wav
bird07.wav         P2.wav
buzzer.wav         p3.wav
chimes_01.wav      P4.wav
egg_timer.wav      P5.wav



----------------------------------
Next concatenate that two columns to get the desired output for BRUs "Renaming From A Text File" feature.

In Cell C1 type this formula : =A1 & "|" & B1

Be inside Cell C1 and left double click at the bottom right corner (at the bigger square there)

The formular is copied down all the rows as column A has values in that rows.
Code: Select all
alarm_01.wav    P1.wav   alarm_01.wav|P1.wav
bird07.wav      P2.wav   bird07.wav|P2.wav
buzzer.wav      p3.wav   buzzer.wav|p3.wav
chimes_01.wav   P4.wav   chimes_01.wav|P4.wav
egg_timer.wav   P5.wav   egg_timer.wav|P5.wav



----------------------------------
Now Copy the Column C and save as a simple Text file.

In BRU use the "Renaming From A Text File" feature.

Code: Select all
     1. Select the folder which contains the objects you wish to rename.
     2. Select the files you wish to process (use CTRL or SHIFT to select multiple files, or use Ctrl+A to select all).
     3.  Enter the renaming criteria. >> Here, click the Import option on the File menu and load your file.
             If the file is valid then you will see the "new name" column reflecting the contents of the text file.
     4. Hit the Rename button. (This button is not enabled unless you have selected one or more files/folders to rename!)





HTH? :D
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Renaming From A Text File

Postby Stefan » Fri Jun 19, 2015 1:08 pm

SCRIPT to Concatenate two file lists together for Bulk Rename Utility's "Renaming From A Text File" feature.


1) First create a list of current names:
Open a DOS-Box via Start > Run > cmd
Be sure to be in the right folder, then type
Dir /b > FileList.txt


2) Execute the AHK script below


3) Next select that list with the origin names.
Origin 1.ext
Old Name 2.ext
...


4) Then you are prompted to select the list with the wanted names (That you have already. Or create as Origin names list too)
New Name.exe
Wanted Name2.exe
...


At the end you will get a new file with:
Origin 1.ext|New Name.exe
Old Name 2.ext|Wanted Name2.exe
...

In BRU use the "Renaming From A Text File" feature.

1. Select the folder which contains the objects you wish to rename.
2. Select the files you wish to process (Ctrl+A to select all).
3. Click the Import option on the File menu and load the file: __BRU_TextFile.txt
You will see the "new name" column reflecting the contents of the text file.
4. Hit the Rename button. (Enabled only if you have selected something!)



The AutoHotkey1.0 Script
(Needs AHK: http://ahkscript.org/download/1.0/AutoHotkey104805.zip)
Code: Select all
;REM AutoHotkey1.0 Script , v0.001, Stefan 2015-06-19
;REM Purpose: Join Two Lists Together (JTLT) for Bulk Rename Utility's "Renaming From A Text File" feature.
;REM          http://www.bulkrenameutility.co.uk/forum/viewtopic.php?f=4&t=2555&p=6743#p6743
;REM Example line: "Origin file name.ext|New Filename.ext"
;REM Needs AHK: http://ahkscript.org/download/1.0/AutoHotkey104805.zip
;====================================================================
#SingleInstance force
OutFile = __BRU_TextFile.txt
;====================================================================

HelpMessage =
(
Merge two list together for BRUs "Renaming From A Text File" feature.

1) First create a list of current names:
Open a DOS-Box via Start > Run > cmd
Be sure to be in the right folder, then type
Dir /b > FileList.txt

2) Execute this AHK script

3) Next select that list with the origin names.
Origin 1.ext
Old Name 2.ext
...

4) Then you are prompted to select the list with the wanted names.
New Name.exe
Wanted Name2.exe
...

At the end you will get a new file with:
Origin 1.ext|New Name.exe
Old Name 2.ext|Wanted Name2.exe
...
)
MsgBox,,JTLT Help message,%HelpMessage%
;====================================================================
FileSelectFile, ListNo1,,%A_WorkingDir%,Select list-file with origin names
If ListNo1 !=
{
    SplitPath, ListNo1,,sLastUsedFolder
    FileSelectFile, ListNo2,,%sLastUsedFolder%,Select list-file with wanted names
    If ListNo2=
        GoSub, ErrorMessage
}
;====================================================================
Loop,Read,%ListNo1% 

  iZEILE++ 
  FileReadLine,sCurrLineFile1,%ListNo1%,%iZEILE%
  FileReadLine,sCurrLineFile2,%ListNo2%,%iZEILE%
  outArray .= sCurrLineFile1 "|" sCurrLineFile2 "`r`n"


If outArray=
    Return
FileDelete,             %OutFile%
FileAppend, %outArray%, %OutFile%
DoneMessage =
(
File list created.

In BRU use the "Renaming From A Text File" feature.

1. Select the folder which contains the objects you wish to rename.
2. Select the files you wish to process (Ctrl+A to select all).
3. Click the Import option on the File menu and load the file: __BRU_TextFile.txt
You will see the "new name" column reflecting the contents of the text file.
4. Hit the Rename button. (Enabled only if you have selected something!)
)
MsgBox,,JTLT All Done!,%DoneMessage%

Run,%OutFile%
ExitApp
;====================================================================
ErrorMessage:
ErrorMessage = ERROR: Please select two files, one with origin names, one with wanted names.
ErrorMessage = %ErrorMessage%`n`nRun Script again!`n`nHelp:`n`n%HelpMessage%
MsgBox,,JTLT ERROR !!!,%ErrorMessage%
ExitApp
;====================================================================



HTH? :D
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Renaming From A Text File

Postby Stefan » Mon Oct 26, 2015 2:54 pm

Would like Sentence Case only after a certain point.
New postby vdofan » 25 Oct 2015, 23:26

>>>I would like just for everything after the spacedashspace " - " to be sentence case.
>>>So that the author's names won't be effected in any way.

For example:

FROM:
Arthur, Dent R.R. - Don't panic.PDF
John S. C. Abbott - The Iron Dragon's Daughter.PDF
Marvel, J.R.R. - Pumuckl aus Lönneberga.PDF
Thomas B. Allen - When the King Comes Home.PDF


TO:
Arthur, Dent R.R. - Don't panic.pdf
John S. C. Abbott - The iron dragon's daughter.pdf
Marvel, J.R.R. - Pumuckl aus lönneberga.pdf
Thomas B. Allen - When the king comes home.pdf

- - -

Answer:

Partly case change is not supported by BRU.

But you can use a scripting language to perform the manipulation
and then utilize BRUs' "Renaming From A Text File" feature.


For example you can use PowerShell to create such a list (join that next two line first):

$A="";$L="";Dir * - * |
ForEach{$A=$_.Name -split(" - ");$L+=$_.Name+"|"+($a[0]+" - "+$a[1].substring(0,1).toupper()+$a[1].substring(1).tolower())+"`r`n"};$L > _Rename-pairs.txt



Execute that line in a PowerShell console, after you have changed the current working directory to the folder of your files.
(Best work on copies of your real files)


_Rename-pairs.txt will contain now:

Arthur, Dent R.R. - Don't Panic.pdf|Arthur, Dent R.R. - Don't panic.pdf
John S. C. Abbott - The Iron Dragon's Daughter.pdf|John S. C. Abbott - The iron dragon's daughter.pdf
Marvel, J.R.R. - Pumuckl Aus Lönneberga.pdf|Marvel, J.R.R. - Pumuckl aus lönneberga.pdf
Thomas B. Allen - When The King Comes Home.pdf|Thomas B. Allen - When the king comes home.pdf



In BRU use the "Renaming From A Text File" feature (File > Import Rename-pairs) to import that list.

If everything looks fine, go ahaed and [Rename]


- - -

A little explanation of that script:

$A="";$L=""; >> empty the vars

Dir * - * >> List the content of the current folder with all files containing " - " in name.

ForEach{ >> For each file do....

$A=$_.Name -split(" - "); >> split the name at the " - " into two parts

$L+=$_.Name >> new var with origin name
+"|" >> add a pipe symbol
+($a[0] >> plus first part of $a
+" - " >> get back the " - "
+$a[1].substring(0,1).toupper() >> first sign to upper case
+$a[1].substring(1).tolower()) >> rest to lower
+"`r`n" >> add line breaks

};
$L > _Rename-pairs.txt >> output, write a file in current folder




- - -


BTW:

If you would not need the preview feature of BRU, you can also just rename the files with PowerShell in one go too:

Dir * - * | %{ $a = $_ -split(" - ") ; ren $_ ($a[0] + " - " + $a[1].substring(0,1).toupper() + $a[1].substring(1).tolower()) }




 
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to BRU Support