Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

349.Batch file rename -- How can I rename files from a specified string inside of a text file? (Not on the first line.)

User: Ben Huffman -- 2009-08-26          << 348  350 >>
Hits: 567
Type: Batch file rename   
Search all Batch file rename examples
Description:
How can I rename files from a specified string inside of a text file? (Not on the first line.)
Input Sample:
I would like to leave the original content of the file untouched and rename it using data contained in the file.
(Note: I have ~800 files to do)
Text contained within text file is

STR(12) ' C12/m1
phase_name "Actinolite"
' Formula "Na0.8 Ca1.73 Mg1.88 Mn0.16 Fe2.72 Fe0.32 Al0.32 Si7.68 O22 (OH)2"
' Group "Silicate"
' SubGroup "Amphibole"
' UserGroup ""
' SubstSeries "Actinolite"
' ICDD_number 250157
a a_actinoli 9.8900 min
Output Sample:
Desired file name output would be
Actinolite_Na0.8 Ca1.73 Mg1.88 Mn0.16 Fe2.72 Fe0.32 Al0.32 Si7.68 O22 (OH)2_250157

"phase_name"_"Formula"_"ICDD_number".str

I understand that this may be overly complex, but I thought I would ask so I don't have to try to code something from scratch. Is it even possible to grab information from something other than the first line? Maybe Do it in steps by leaving the original file name and adding one line at a time?

Thanks regardless of the outcome.
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
This is a challenge, but not for Replace Pioneer:
*** require Replace Pioneer 2.44 and above ***
1. open menu "Tools->Batch Runner" 
2. click "Pick Files" to select multiple files 
3. check "Set output filename" option, change ${FILENAME} to: 

4. check if the new name in "output file" column is correct. 
5. click "File Rename", done.

Note: 
1. above procedure may not be very efficient, since it read each file 3 times.
2. if your content are not in first 1000 bytes, but within first 3000 bytes, use 

Screenshot 1:  Batch_Runner_Window


Similar Examples:
How to remove all lines that contain some specific strings in a text file? (57%)
How to exract specified strings started with www from text file? (54%)
How to extract multiple lines in specified order from many text files? (54%)
How to insert a line after specific lines in a text file? (54%)
How to rename many files with the last modified date of the file? (54%)
How to extract all lines with specified date range from text file? (53%)
How to change the number in each line to specified order in a text file? (53%)
How to change columns in each line to specified order in text file? (53%)

Check Demo of Batch file rename
Keywords:
first 10  inside  times  correct  bytes  names  byte  content  100  string  rename to first line of text  rename text file from first line  rename files to the first line of text  rename text files first line  rename text file to first line  rename file to first line of text  rename first line in text file  text rename first line