V
V
vashruslan2016-01-11 11:32:03
cmd/bat
vashruslan, 2016-01-11 11:32:03

How to rename many pdfs based on multiple lines of data?

Please help science, fellow programmers. Thank you very much in advance.
1. There are a lot of scientific articles with arbitrary names.
2. We need a batnik that can rename them.
3. There is a special utility pdftotext, after processing which produces txt.

for /r %%a in (*.pdf) do (
pdftotext "%%a" "%%a".txt
)

You need to form a name based on the data on lines 1, 6 and 7 of the txt file.
This is what txt looks like
Materials Science and Engineering A 552 (2012) 295­300
Contents lists available at SciVerse ScienceDirect
Materials Science and Engineering A
journal homepage: www.elsevier.com/locate/msea

Structure and mechanical properties of Ti­6Al­4V alloy after zirconium addition
R. Jing, S.X. Liang, C.Y. Liu, M.Z. Ma, X.Y. Zhang, R.P. Liu 
State Key Laboratory of Metastable Materials Science and Technology, Yanshan University, Qinhuangdao 066004, China

article info
Article history: Received 9 April 2012 Received in revised form 14 May 2012 Accepted 15 May 2012 Available online 24 May 2012
Keywords: TiZrAlV alloys Solid solution strengthening Microstructure Mechanical properties

abstract
In this paper, zirconium (Zr) is selected as a partial substitutable element for titanium (Ti) in Ti­6Al­4V (TC4) alloy to fabricate series of TiZrAlV quaternary alloys. Mechanical testing, microhardness testing, metallographic analysis, X-ray diffraction, and fracture analysis are performed to evaluate the microstructure and mechanical properties of the alloys. The tensile strength and microhardness are found to increase with increased Zr content, whereas the elongation ratio decreases with gradually increased Zr content. The morphology of  phase suffers a series of changes with the increase of Zr content. The  phase contents of the alloys studi

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Max, 2016-01-11
@MaxDukov

well, add a counter to the loop, with the counter value of 1.6 and 7, add the line to the variable in which you will collect the sum of the lines. rename the file after the loop.

O
Olgeir, 2016-01-12
@Olgeir

If in lines 1,6,7 there are characters that CMD perceives as control, then garbage will turn out, if there are no such characters, then
@echo off
set LOG=log.log
for /r %%a in (*.pdf) do call :process " %%~na"
exit 0
:process
set f=%~1
set p="%f%.pdf"
set t="%f%.txt"
pdftotext %p% %t%
for /f "tokens=* delims =" %%a in (%t%) do set s=%%a&goto n1
:n1
for /f "skip=5 tokens=* delims=" %%a in (%t%) do set s=%s% %%a&goto n6
:n6
for /f "skip=6 tokens=* delims=" %%a in (%t%) do set s=%s% %%a&goto n7
:n7
echo OLD=[%p%] NEW =[%s%.pdf]>>%LOG%
copy %p% %s%.pdf
goto :eof

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question