hello
I have a directory containing mostly pdfs which I have gathered from all over the internet. I now want to sort them into directories in a more structured mannar based on their contents. To do this, I am running pdftotext to preview the contents then moving them to another dir based on what I read.
Code:
ls
pdftotext afilename.pdf | less
mv afilename.pdf adir
Now, I am particularly lazy and am trying to work out a fast way to repeat this process for different files. (Even though the length of time I have spent trying to work this out is longer that it would have taken me to do it anyway...)
The main aim is to take the second line and replace the first argument with a different file name.
Much reading as lead me to this route:
Code:
!-2:s/afilename.pdf/anewfilename.pdf/
However, this has 2 flaws.
1) I don't want to have to type the old argument
2) I don't really want to have to type all of the new argument either. Bash's Tab completion doesn't seem to work at the end of a string like that.
The first problem can be partly overcome with:
Which will yank the first argument of the previous command. It doesn't solve the second one though.
This seems a very indirect route to perform this substitution. Is there a better solution? Perhaps the s/ operator can take a regexp that refers to the argument rather than a string?