LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-28-2009, 09:14 AM   #1
metalme
LQ Newbie
 
Registered: Sep 2009
Posts: 1

Rep: Reputation: 0
Need to convert a large number of file types from none standard to txt


I have on my windows machine several hundred files that are a format of .nc .ncs for a CNC machine. I need to convert them to txt which is something as easy as opening in notepad and then saving as .txt but there are so many that this kind of action would take way too long.

The reason I am writing the linuxquestions is because I would feel more comfortable in loading a live CD and using some sort of terminal command to do this than I would to download one of the many "freeware" type programs I have found for windows (even more so since I have had a root kit before and had to start all the way over to get rid of it).

I need to know:

1. Is this possible to do with the terminal without super advanced knowledge.

2. Can one please point me in the right direction; something to read or an example
 
Old 09-28-2009, 12:30 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
It sounds like you need to simply rename the files. If this is the case, then a simple bash script can easily do this. First thing to do is backup the files, because you don't want to practice shell scripting on your only copy of the files (duh...).

This should get you started. You can either make it into a shell script, or just run the commands from a commandline, since it is evidently a one-shot process.
Code:
for cncfile in *.nc;  do echo mv $cncfile $( basename $cncfile ".nc"  ).txt; done
for cncfile in *.ncs; do echo mv $cncfile $( basename $cncfile ".ncs" ).txt; done
Run the script/commandline, and when you are satisified that it will do the right thing, remove the 'echo' command, to have it actually perform the deed.
If the files need to be processed in some way, you will need to specify what changes need to be performed.

--- rod.

Last edited by theNbomr; 09-28-2009 at 12:32 PM.
 
Old 09-28-2009, 05:46 PM   #3
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
It's a little hard to google details on .nc, .ncs, & CNC, however, it seems they are basically ascii text files containing the numerical control command language and with the extension .nc. That would be similar to a C program, which contains C program language in ascii text format and has a .c extension. One of the standard .nc formats was derived from the Gerber Plotter file format.

Anyway, that basically supports theNbomr's assumption that renaming is all that is required. His two lines of code look good, as well as his suggestion to test with the echo in place first. I would also make a backup of the files before proceeding just as a standard precaution.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gawk/awk/tcsh - how to convert large number to human readable (Mb,Gb, etc)? BrianK Programming 23 10-30-2010 04:20 AM
Short-circuited file types - .doc, .txt stuck on same app darenw Linux - Software 0 03-27-2009 09:07 PM
How to find which file has a string when large number of files dwynter Linux - Newbie 2 09-10-2008 06:06 AM
Help with script to convert different Video file types to wmv format for streaming farmerjoe Programming 1 11-17-2005 01:12 PM
How to convert a txt file to be a db file in Redhat linux 9? winnie Linux - Newbie 3 06-27-2003 08:33 AM


All times are GMT -5. The time now is 11:54 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration