Please use ***
[code][/code] tags*** around your code and data, to preserve formatting and to improve readability. Please do
not use quote tags, colors, or other fancy formatting.
Try something like this:
Code:
while read -r filename xx title ; do
mv "$filename.pdf" "$title.pdf"
done <file
It reads the string into 3 variables, with the second one (xx) being discarded, as it only captures the hyphen between the two desired strings. Then mv is run using them.
This is just a skeleton though. You should really add some code to clean up the title names a bit before
mv'ing to them, such as replacing spaces with underscores and removing shell-reserved characters.
It will also only run in the current working directory at this point. You'd have to add extra path strings if you wanted to run it on an arbitrary location.
How can I read a file (data stream, variable) line-by-line (and/or field-by-field)?
http://mywiki.wooledge.org/BashFAQ/001
How do I do string manipulations in bash?
http://mywiki.wooledge.org/BashFAQ/100