Find the answer to your Linux question:
Results 1 to 2 of 2
Hi- This may be an advanced question but I need to know how to do this. Here at work I am in charge of recruiting and we have about 1,000 ...
  1. #1
    Just Joined!
    Join Date
    Jan 2010
    Posts
    3

    [SOLVED] Help! Loop append text to text files

    Hi-

    This may be an advanced question but I need to know how to do this. Here at work I am in charge of recruiting and we have about 1,000 resumes in already. All of the resumes are in a .pdf format. I need to rename every .pdf in the following format:
    {firstnameLastname}.pdf

    The only way I know how to do this is to convert all the .pdf files to text, extract the name out of the first few lines of text, import into excel, and then use VBA to rename the files in mass:

    Here is my logic so far:

    ~Deskop/a = houses all the .pdf resumes

    Open terminal:

    Code:
    cd ~/Desktop/a
    for f in *.pdf; do pdftotext -raw $f; done
    That will convert all of the preceding resumes into text files

    Now I would like to append the name of the text file into the last line of the text file. So, for example, for Resume1.txt, I want to append "Resume1.txt" to the last line within Resume1.txt. So after I run the command I open Resume1.txt and on the last line within I want to see "Resume1.txt" on the last line, at the end of the resume.

    How can I do this? I would like to use a loop and have the terminal append the filename to the body of the text file until all of the have been appended. This would help me so much

    I hope this makes sense, if not, ask me and I will clarify

  2. #2
    Just Joined!
    Join Date
    Jan 2010
    Posts
    3
    Nevermind:

    See:
    unix.com/unix-dummies-questions-answers/104659-prepend-add-file-name-beginning-file.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...