Save files in directory as txt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Save files in directory as txt
# 8  
Old 12-12-2014
Code:
 
head -3 tcode-pdf.txt
CM080 test-pdf.php?testid=4318
CM081 test-pdf.php?testid=4401
CM082 test-pdf.php?testid=4400

Code:
 
ls C:\Users\cmccabe\Desktop\list\geneticslab.emory.edu.txt\tests2\geneticslab.emory.edu\tests | head -3
ls: cannot access C:UserscmccabeDesktoplistgeneticslab.emory.edu.txttests2geneticslab.emory.edutests: No such file or directory

Does this help? Thank you Smilie.
# 9  
Old 12-12-2014
Yes and no Smilie (The output of head -3 tcode-pdf.txt helped quite a lot, it indicates that the big awk command worked as expected)

You said
Quote:
all the newly created files are in a new file path:
C:\Users\cmccabe\Desktop\list\geneticslab.emory.edu.txt\tests2\geneticslab.emory.edu\tests
but even if I do a cd to that directory I get the same error.
Can you please cd to that directory again and run ls | head -3 and post the output?
# 10  
Old 12-12-2014
Code:
 
ls | head -3
tcode-pdf.txt
test-pdf.php@testid=4125
test-pdf.php@testid=4143

I manually copied over the tcode-pdf.txt as it was not there. Thanks for your help Smilie.

I also attached tcode-pdf.txt if that helps Smilie.
This User Gave Thanks to cmccabe For This Post:
# 11  
Old 12-12-2014
Bullseye!! Smilie
Code:
tcode-pdf.txt
test-pdf.php@testid=4125
test-pdf.php@testid=4143

If you look at those pdf files, you'll notice how the question-mark turned to a at sign (@), it must have happend during the download, for whatever the reason. THAT is the reason why awk could not find the required/expected files...

The tcode-pdf.txt file is almost perfect.
There are 98 records, one is defective/superfluous, fix it with this command:
Code:
sed -i '/AACE/d' tcode-pdf.txt

This command will turn the question-marks to at-signs:
Code:
sed -i 's/\?/@/' tcode-pdf.txt

Now, finally, it's time to try it again:
Code:
awk '{ A[$1]=$2; next} END { for (i in A) print "mv \x27"A[i]"\x27",i".pdf" }' tcode-pdf.txt | sh

Knock on wood! Smilie
This User Gave Thanks to junior-helper For This Post:
# 12  
Old 12-13-2014
I ran the two
Code:
 sed

commands and attached tcode-pdf and list2 and here is the output of
Code:
 $ ls | head -3
CM080
CM081
CM082

The actually names appear to be different then the created files.

I get
Code:
 mv: cannot stat `test-pdf.php@testid=4421': No such file or directory
mv: cannot stat `test-pdf.php@testid=4415': No such file or directory
mv: cannot stat `test-pdf.php@testid=4434': No such file or directory
mv: cannot stat `test-pdf.php@testid=4391': No such file or directory

I tried running the
Code:
 awk

commands in both directories (the original and the newly created one). Which directory should I be in? Thank you for your help Smilie.
# 13  
Old 12-13-2014
It looks like the lists2.txt also needed the
Code:
 sed

command to change the ? to @. So could
Code:
 sed -i 's/\?/@/' tcode-pdf.txt list2.txt

be used to convert them at the same time?

Is there a way to automatically copy tcode-pdf.txt to the newly created directory. Does this command need to be modified:
Code:
  wget -x -i /tmp/list2.txt

when I run
Code:
 for i in *.pdf; do
done>  pdftotext "$i"
> done
-bash: pdftotext: command not found
-bash: pdftotext: command not found
-bash: pdftotext: command not found
-bash: pdftotext: command not found
-bash: pdftotext: command not found

I am using cygwin on windows (I know its not ideal, but its what I haave to use). Is there a command to install a package (poppler I believe) in the cygwin bin directory located here:

Code:
 C:\cygwin\bin

Thank you Smilie.

---------- Post updated at 11:40 AM ---------- Previous update was at 09:53 AM ----------

I got it to work on a linux machine... it definatly makes it easier to parse and I like the command. I appreciate all your help and will use that command as well as another I need help on and will post on Monday. Thank you Smilie.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dig and concatenate all files yesterday then save it to another directory

I dont want to use for loop since it is using a lot of resources especially to a thousand files. Wanting to have a while? or something will find files that has been modifed or created yesteraday. View it. And search for soemthing and save it to a certain folder. for i in `find ./ -mtime... (3 Replies)
Discussion started by: invinzin21
3 Replies

2. UNIX for Beginners Questions & Answers

How can i add each line from a txt file to different files in the same directory?

Hello, this is my first thread here :) So i have a text file that contains words in each line like abcd efgh ijkl mnop and i have 4 txt files, i want to add each line to each file, like file 1 gets abcd at the end; file 2 gets efgh at the end .... I tried with: cat test | while read -r... (6 Replies)
Discussion started by: azaiiez
6 Replies

3. Shell Programming and Scripting

Cpio all *.txt-files out of folders to just one directory

I need a hint for reading manpage (I did rtfm really) of cpio to do this task as in the headline described. I want to put all files of a certain type, lets say all *.txt files or any other format. Spread in more than hundreds of subdirectories in one directory I would like to select them and just... (3 Replies)
Discussion started by: 1in10
3 Replies

4. Shell Programming and Scripting

Get the input from user and save it as .txt file

Hi friends, I am pretty new to shell scripting, please help me in this Scenario. for example, If I have one file called input.txt once I run the script, 1.It has to delete the old input.txt and create the new input.txt (if old input.txt is not there, no offence, just it has to create a... (2 Replies)
Discussion started by: Padmanabhan
2 Replies

5. Shell Programming and Scripting

I need to back up a bunch of files on a directory and save that file as the current date....

this is what i have to find the files modified within the past 24 hours find . -mtime -1 -type f -print0 | xargs -0 tar rvf "$archive.tar" however i need to save/name this archive as the current date (MM-DD,YYYY.tar.gz) how do i doo this (1 Reply)
Discussion started by: bugenhagen_
1 Replies

6. Shell Programming and Scripting

Pattern search and save it as .txt file with some name..

Hello, I have a note pad at /usr/abc location with the following content, since it is a huge file i need to split it into multiple .txt files. A123|akdhj |21kjsdff |b212b1b21 |0 A123asdasd |assdd |asdasdsdqw|6 A123|QEWQ |NMTGHJK |zxczxczx|3 A123|GEGBGH |RTYBN ... (15 Replies)
Discussion started by: j_panky
15 Replies

7. Shell Programming and Scripting

moving the files in a.txt files to a different directory

HI All, I am coding a shell script which will pick all the .csv files in a particular directoryand write it in to a .txt file, this .txt file i will use as a source in datastage for processing. now after the processing is done I have to move and archive all the files in the .txt file to a... (5 Replies)
Discussion started by: subhasri_2020
5 Replies

8. Shell Programming and Scripting

Checking if the files in a directory have a txt extension

foreach file ($dir1/*) if ($file ~ *.txt) then echo "Skipping $file (is a txt file)" endif end that should work right guys? :confused: (15 Replies)
Discussion started by: pantelis
15 Replies

9. UNIX for Dummies Questions & Answers

List all files except *.txt in a directory

I have many types of files (Eg: *.log, *.rpt, *.txt, *.dat) in a directory. I want to display all file types except *.txt. What is the command to display all files except "*.txt" (9 Replies)
Discussion started by: apsprabhu
9 Replies

10. Shell Programming and Scripting

Read from fileList.txt, copy files from directory tree

Hi, hopefully this is a fairly simple Q&A. I have a clean file list of approximately 180 filenames with no directory or slashes in front of the filename nor any extension or dot ".". I would like to read from this list, find these files recursively down through directory trees, copy the files... (1 Reply)
Discussion started by: fxvisions
1 Replies
Login or Register to Ask a Question