rusty with cp command -- how to cp all .doc files with .txt extension


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers rusty with cp command -- how to cp all .doc files with .txt extension
# 1  
Old 04-08-2011
rusty with cp command -- how to cp all .doc files with .txt extension

I'm rusty with cp, so I was wondering: is it possible to cp all the .doc files in a folder and make them .txt files? Can you use cp to do that?
# 2  
Old 04-08-2011
all at once? no.

you could do this:

Code:
for FILE in /path/from/*.doc
do
        cp "$FILE" "/path/to/${FILE/%doc/txt}"
done

Just renaming a .doc file into .txt won't actually make a .doc file into a .txt file, of course.
# 3  
Old 04-11-2011
You'd need the "mv" command to do that.
# 4  
Old 04-11-2011
Quote:
Originally Posted by methyl
You'd need the "mv" command to do that.
However the 'mv' command will rename/delete the original *.doc file.

You might be better off, logically, copying the original *.doc files to another separate directory, and then perform a 'mv *.doc to *.txt

That way you still have all your original files in native format.

As stated previously, just changing the extension, does not change the filetype.

EDIT: You'd need the "mv" command to do that. Does NOT mean the 'mv' command will convert the file.
I have confidence methyl knows this and just didn't explain it very well.

Last edited by AlphaLexman; 04-11-2011 at 06:42 PM..
This User Gave Thanks to AlphaLexman For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get a variables from two different txt files and need to run a command using that values?

Hi Q1. I have a scenario to run cfsend command,this command will run based on node name,port num,userid and password I was created one file called test.txt and inserted two values,then called those two values from test.txt file that pointed to node place and ran the script it worked fine Now... (10 Replies)
Discussion started by: venuvaka
10 Replies

2. UNIX for Dummies Questions & Answers

Display the .csv extension files based on .done extension fine

Hi All, I want to fetch the files based on .done file and display the .csv files and Wil take .csv files for processing. 1.I need to display the .done files from the directory. 2.next i need to search for the .Csv files based on .done file.then move .csv files for the one directory ... (2 Replies)
Discussion started by: girija.g6
2 Replies

3. Shell Programming and Scripting

[Solved] Giving files .txt extension

Hi there, I have around 145,000 files with no file extension in this directory - /home/adams/29: The file name varies but all end with a number from 0 - 9, e.g. TTFILE_BAT_235496, CCNHATA_RFC_23455 I want to give all these 145,000 .txt extension. Please how do I do that? Thanks (2 Replies)
Discussion started by: Creems
2 Replies

4. UNIX for Dummies Questions & Answers

Find command to exclude files with no extension

The below 'ls' command will list down files with extensions and suppress the ones with no extension ls |grep "\\." But this dosen't work when I apply the same logic using 'find' command find . -type f |grep "\\." I need help on how this logic can be implemented using 'find' command (3 Replies)
Discussion started by: meenavin
3 Replies

5. Shell Programming and Scripting

ksh command to rename all files with no extension

hi! i want to rename all files with no extension with the extension DAT. with this command ls |grep -v "\\." i can list files but i dont know how i am going to rename them.. so i tried FILE_LIST=ls |grep -v "\\." for TEST_FILE in ${FILE_LIST} do mv $TEST_FILE... (2 Replies)
Discussion started by: kouppoua
2 Replies

6. 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

7. Shell Programming and Scripting

Spool file with .txt extension

Hi I am logging into sql using script. sqlplus ima/ima@test <<! spool /opt/tt/spoolfile.txt @sql.sql spool off. now i am getting a spool file named spoolfile.txt.lst i want it to be only spoolfile.txt I am working on solaris Please help (6 Replies)
Discussion started by: ankurk
6 Replies

8. Shell Programming and Scripting

Script to run a command on all txt files present in a dir structure

Hi, I have a directory structure like the one given below root\a\b1 root\a\b2 root\b\b1 root\b\b2 . . . root\j\b1 root\j\b2 Now, there are a txt files in each dir and subdir, there is a root.txt I have to write a script where in i have to run a command called "genrb <filename>"... (6 Replies)
Discussion started by: vikramsinghnegi
6 Replies

9. Shell Programming and Scripting

how to convert XLS to CSV and DOC/RTF to TXT

Hi, i don't know anything about PERL. Can anyone help me providing PERL scripts for 1. converting XLS to CSV (and vice-versa) 2. converting DOC/RTF to TXT Thanks much Prvn (1 Reply)
Discussion started by: prvnrk
1 Replies

10. Solaris

list files .txt and .TXT in one command

Dear experts, In a directory i have both *.TXT and *.txt files. I have a script- for file in `ls *.txt`; do mv $file /tmp/$file How to list both *.txt and*.TXT file in one command so that script will move both .txt or .TXT whatever it find. br//purple (4 Replies)
Discussion started by: thepurple
4 Replies
Login or Register to Ask a Question