<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3216754183466278326</id><updated>2012-02-16T02:29:09.699-08:00</updated><category term='multiple files'/><category term='rename multiple files'/><category term='pie chart'/><category term='JAVA'/><category term='client'/><category term='private pipe'/><category term='rename files'/><category term='jframe'/><category term='server client'/><category term='well known pipe'/><category term='pie chart editor'/><category term='renamer'/><category term='server'/><category term='music files'/><category term='rename'/><category term='java pie chart program'/><category term='JAVA GUI'/><category term='code'/><category term='folders'/><category term='java code'/><category term='C programming'/><category term='.java'/><title type='text'>Archuthan's Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://archuthan.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3216754183466278326/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://archuthan.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Archuthan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3216754183466278326.post-8706366572523549351</id><published>2009-07-28T20:36:00.000-07:00</published><updated>2011-02-13T23:30:48.021-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jframe'/><category scheme='http://www.blogger.com/atom/ns#' term='renamer'/><category scheme='http://www.blogger.com/atom/ns#' term='rename'/><category scheme='http://www.blogger.com/atom/ns#' term='music files'/><category scheme='http://www.blogger.com/atom/ns#' term='code'/><category scheme='http://www.blogger.com/atom/ns#' term='folders'/><category scheme='http://www.blogger.com/atom/ns#' term='rename files'/><category scheme='http://www.blogger.com/atom/ns#' term='java code'/><category scheme='http://www.blogger.com/atom/ns#' term='multiple files'/><category scheme='http://www.blogger.com/atom/ns#' term='rename multiple files'/><category scheme='http://www.blogger.com/atom/ns#' term='JAVA'/><title type='text'>Java - The Renamer!</title><content type='html'>When a disaster striked my computer, I lost all my music files. :(  If its any other portable music player, I would've just drag the songs from it to my computer. I don't think Apple made that easier for IPOD TOUCH users. So, I downloaded &lt;a href="http://www.getsharepod.com/"&gt;SharePod&lt;/a&gt; to copy the songs to my computer. But songs were renamed to the following format.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;TrackNo - Title.mp3&lt;/span&gt;&lt;br /&gt;But my track number was 00, for all of the songs. So I had all the songs with the following format.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;00 - Beat It.mp3&lt;/span&gt;&lt;br /&gt;I didn't like that format, I just wanted the song name. I knew it would take atleast a day for me to rename all the songs manually. Only thing came to my mind was, SHELL SCRIPT. I am not very expert in shellscripting but with Window's Vista, all I could use is DOS. Did few google search and wasn't successfull with the google search, I decided to do my own multiple files renamer. Since, Java provides most of the functionality I needed to do this program, I went with Java.&lt;br /&gt;Here is the code below. Just run the program like this (don't change any code, uncomment anything) and see if the output of your renamed files are correct. If its correct then you could uncomment the bolded 2 lines of code which will actually rename the original files.&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;import java.awt.FlowLayout;&lt;br /&gt;import java.io.File;&lt;br /&gt;import javax.swing.JFrame;&lt;br /&gt;import javax.swing.JTextArea;&lt;br /&gt;import javax.swing.JScrollPane;&lt;br /&gt;import javax.swing.JFileChooser;&lt;br /&gt;import javax.swing.JOptionPane;&lt;br /&gt;public class FilesRenamer&lt;br /&gt;{&lt;br /&gt;    public static void main(String[] args) throws Exception&lt;br /&gt;    {&lt;br /&gt;        JTextArea text = new JTextArea(15, 30);&lt;br /&gt;        text.setText("Original Files:\nRenamed Files:\n\n");&lt;br /&gt;&lt;br /&gt;        File selected[];&lt;br /&gt;&lt;br /&gt;        JScrollPane scroll = new JScrollPane(text);&lt;br /&gt;&lt;br /&gt;        JFileChooser chooser = new JFileChooser("C:\\Users\\Owner\\Music");&lt;br /&gt;        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);&lt;br /&gt;        chooser.setMultiSelectionEnabled(true);&lt;br /&gt;&lt;br /&gt;        JFrame f = new JFrame("Multiple Files Renamer");&lt;br /&gt;        f.setLayout(new FlowLayout());&lt;br /&gt;        f.add(scroll);&lt;br /&gt;        f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);&lt;br /&gt;        f.setSize(500, 600);&lt;br /&gt;        f.setVisible(true);&lt;br /&gt;&lt;br /&gt;        int returnVal = chooser.showOpenDialog(f);&lt;br /&gt;        if (returnVal == JFileChooser.APPROVE_OPTION)&lt;br /&gt;        {&lt;br /&gt;            selected = chooser.getSelectedFiles();&lt;br /&gt;            if (selected.length == 1 &amp;amp;&amp;amp; !selected[0].exists())&lt;br /&gt;                JOptionPane.showMessageDialog(null,&lt;br /&gt;                  "File does not exists!", "Alert!",&lt;br /&gt;                  JOptionPane.ERROR_MESSAGE); &lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                for (int i=0; i&amp;lt;selected.length; i++)&lt;br /&gt;                {&lt;br /&gt;                    text.append(selected[i].toString() + "\n");&lt;br /&gt;                    String temp = newname(selected[i]);&lt;br /&gt;                    if (temp != null)&lt;br /&gt;                    {&lt;br /&gt;                        text.append(temp + "\n\n");&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        chooser.setSelectedFile(null);&lt;br /&gt;    }&lt;br /&gt;    public static String newname(File fullpath)&lt;br /&gt;    {     &lt;br /&gt;        String newfilename = fullpath.getName();&lt;br /&gt;        newfilename = newfilename.substring(5);&lt;br /&gt;        File filedir = new File (fullpath.getParentFile() + "\\" &lt;br /&gt;            + newfilename);&lt;br /&gt;        //if (full.renameTo(filedir))&lt;br /&gt;        return filedir.toString();&lt;br /&gt;        //return null;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Let's say if you want to play with extension, such as to make jpg to jpeg or change from mp3 to wma then add the following function into the code.&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;public static String extension(String filename)&lt;br /&gt;{&lt;br /&gt;    String justFileName = filename.substring(0, filename.lastIndexOf('.'));&lt;br /&gt;    String ext = filename.substring(filename.lastIndexOf('.'));&lt;br /&gt;    ext = ".mp3";&lt;br /&gt;    String newfilename = justFileName+""+ext;&lt;br /&gt;    return(newfilename);     &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;and change the newname function to the following.&lt;br /&gt;&lt;pre class="code"&gt;public static String newname(File fullpath)&lt;br /&gt;{     &lt;br /&gt;    String newfilename = fullpath.getName();&lt;br /&gt;    //newfilename = newfilename.substring(5);&lt;br /&gt;    newfilename = extension(newfilename);&lt;br /&gt;    File filedir = new File (fullpath.getParentFile() + "\\" + newfilename);&lt;br /&gt;    //if (full.renameTo(filedir))&lt;br /&gt;    return filedir.toString();&lt;br /&gt;    //return null;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3216754183466278326-8706366572523549351?l=archuthan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://archuthan.blogspot.com/feeds/8706366572523549351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://archuthan.blogspot.com/2009/07/java-renamer.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3216754183466278326/posts/default/8706366572523549351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3216754183466278326/posts/default/8706366572523549351'/><link rel='alternate' type='text/html' href='http://archuthan.blogspot.com/2009/07/java-renamer.html' title='Java - The Renamer!'/><author><name>Archuthan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3216754183466278326.post-8735534875931794198</id><published>2009-04-15T18:31:00.000-07:00</published><updated>2009-04-22T13:11:10.025-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='server'/><category scheme='http://www.blogger.com/atom/ns#' term='C programming'/><category scheme='http://www.blogger.com/atom/ns#' term='well known pipe'/><category scheme='http://www.blogger.com/atom/ns#' term='private pipe'/><category scheme='http://www.blogger.com/atom/ns#' term='server client'/><category scheme='http://www.blogger.com/atom/ns#' term='client'/><title type='text'>C - Client/Server on a localhost.</title><content type='html'>This is post is about a client/server assignment I did for the Intro to OS course. The client and server has to be running on a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;localhost&lt;/span&gt; and server should be executed before client. Otherwise, it doesn't make sense. You could try running the client first, but no meaningful output will be seen. So, run the server first. (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Ofcourse&lt;/span&gt;, I provided the source code so you need to compile first.)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This the basic idea of the program:&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_KEV5PinkvFM/Se9rVZ3plyI/AAAAAAAAABU/9DO3JcnxkMo/s1600-h/cServerClient.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5327594899668309794" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 158px" alt="" src="http://4.bp.blogspot.com/_KEV5PinkvFM/Se9rVZ3plyI/AAAAAAAAABU/9DO3JcnxkMo/s320/cServerClient.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The server starts and creates a well-known pipe and waits for a client. Whenever a client connects to the server, server waits for client to write sumthing to the well-known pipe. Client will write it's pid, name (a person's name to be looked up in a database) and a char to identify address or phonenumber of the person that client is requesting (a= address or p=phonenumber). Server, then, read this info from well-known pipe and then break down the string into appropriate words(I could've used a string tokenizer, built-in function, but I realized that later. I think, I created a my own string tokenizer.) Using the child's pid, the server creates a private pipe for communicating with the client. Then, the server try to execute the command, on unix system, it formed from the passed-in info from client. If it's successful, then server writes appropriate messages to the client using the private pipe. Then client does some clean up (deletes the private pipe, closes the pipes) and then exits.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;NOTE:&lt;/em&gt;&lt;/strong&gt; Server could only handle one &lt;strong&gt;client at a time&lt;/strong&gt;. To handle more than one client, server should have a queue in which client is added. Then, client is popped one at a time and server would then do a fork function call. That newly created child (of the server) would deal with the request from the client. Server would create another child (fork() again) and deal with the second client and so on.)&lt;br /&gt;&lt;br /&gt;Here is a sample output (I have blurred some of the things that reveals any information about school's server.)&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_KEV5PinkvFM/Se9Vnsq55gI/AAAAAAAAABM/zVJTVAUrdcs/s1600-h/sample_output.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5327571024696960514" style="WIDTH: 356px; CURSOR: hand; HEIGHT: 288px" alt="" src="http://1.bp.blogspot.com/_KEV5PinkvFM/Se9Vnsq55gI/AAAAAAAAABM/zVJTVAUrdcs/s320/sample_output.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;Here is how I ran it:&lt;/strong&gt;&lt;br /&gt;Running server:&lt;br /&gt;1) Started a SSH window for the server.&lt;br /&gt;2) I executed the 'ps' command to show that no other process are running&lt;br /&gt;(other than bash and ps itself)&lt;br /&gt;3) I started the server.&lt;br /&gt;4) Server now waits for a connection from client...&lt;br /&gt;&lt;br /&gt;Running Client:&lt;br /&gt;1) Opened another SSH window for the client.&lt;br /&gt;2) I executed the 'ps' command to show that no other process are running&lt;br /&gt;(other than bash and ps itself)&lt;br /&gt;3) I executed the 'ls' command to list the files in that current directory.&lt;br /&gt;4) I executed the 'cat' cmd with a2.db as the input.&lt;br /&gt;(a2.db is the database file. Data for each record is seperated with a delimiter ':')&lt;br /&gt;5) Client was started.&lt;br /&gt;6) A name was entered; in this case, Mark, since that name is in the database.&lt;br /&gt;7) 'a' was entered to see Mark's address from the database.&lt;br /&gt;8) Client output the results.&lt;br /&gt;(Client exited - automatically.)&lt;br /&gt;9) Client was started again.&lt;br /&gt;10) Will Smith was entered as the name.&lt;br /&gt;11) 'p' was entered to see Will Smith's phonenumber.&lt;br /&gt;12) Client out put the results and exited.&lt;br /&gt;13) I ran the 'dir' command to show that all the pipes have been removed.&lt;br /&gt;(if 'dir' don't work use 'ls')&lt;br /&gt;14) Server was killed by pressing "CTRL + C"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If the above paragraph is confusing, then try reading the code, which is lot easier to understand.&lt;br /&gt;Code:&lt;br /&gt;&lt;a href="http://cid-3e83bfd71e4816b4.skydrive.live.com/browse.aspx/Public/cProgrammingServerClient"&gt;http://cid-3e83bfd71e4816b4.skydrive.live.com/browse.aspx/Public/cProgrammingServerClient&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3216754183466278326-8735534875931794198?l=archuthan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://archuthan.blogspot.com/feeds/8735534875931794198/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://archuthan.blogspot.com/2009/04/c-clientserver-on-localhost.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3216754183466278326/posts/default/8735534875931794198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3216754183466278326/posts/default/8735534875931794198'/><link rel='alternate' type='text/html' href='http://archuthan.blogspot.com/2009/04/c-clientserver-on-localhost.html' title='C - Client/Server on a localhost.'/><author><name>Archuthan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_KEV5PinkvFM/Se9rVZ3plyI/AAAAAAAAABU/9DO3JcnxkMo/s72-c/cServerClient.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3216754183466278326.post-246467391568963607</id><published>2009-04-04T10:45:00.000-07:00</published><updated>2009-04-22T13:11:41.976-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.java'/><category scheme='http://www.blogger.com/atom/ns#' term='pie chart editor'/><category scheme='http://www.blogger.com/atom/ns#' term='pie chart'/><category scheme='http://www.blogger.com/atom/ns#' term='JAVA GUI'/><category scheme='http://www.blogger.com/atom/ns#' term='java pie chart program'/><category scheme='http://www.blogger.com/atom/ns#' term='JAVA'/><title type='text'>Java - Pie Chart Editor/Creator</title><content type='html'>&lt;a href="http://2.bp.blogspot.com/_KEV5PinkvFM/SdeeyWXfvJI/AAAAAAAAAA8/N6P94QXb0_w/s1600-h/piechart.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5320896072596307090" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 317px; CURSOR: hand; HEIGHT: 320px" alt="" src="http://2.bp.blogspot.com/_KEV5PinkvFM/SdeeyWXfvJI/AAAAAAAAAA8/N6P94QXb0_w/s320/piechart.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is one of the assignment I did for JAVA-2 Course.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is the files : &lt;a href="http://cid-3e83bfd71e4816b4.skydrive.live.com/browse.aspx/Public/JAVAPieChart"&gt;http://cid-3e83bfd71e4816b4.skydrive.live.com/browse.aspx/Public/JAVAPieChart&lt;/a&gt;&lt;br /&gt;I think just reading the comments will help a lot. I don't think I need to explain the codes in there.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3216754183466278326-246467391568963607?l=archuthan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://archuthan.blogspot.com/feeds/246467391568963607/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://archuthan.blogspot.com/2009/04/java-pie-chart-editorcreator.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3216754183466278326/posts/default/246467391568963607'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3216754183466278326/posts/default/246467391568963607'/><link rel='alternate' type='text/html' href='http://archuthan.blogspot.com/2009/04/java-pie-chart-editorcreator.html' title='Java - Pie Chart Editor/Creator'/><author><name>Archuthan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_KEV5PinkvFM/SdeeyWXfvJI/AAAAAAAAAA8/N6P94QXb0_w/s72-c/piechart.jpg' height='72' width='72'/><thr:total>3</thr:total></entry></feed>
