Register
It is currently Thu Apr 17, 2014 9:27 am

File renamer script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Wed Nov 15, 2006 1:28 am   

Joined: Wed Nov 15, 2006 1:21 am
Posts: 3
Location: Grand Blanc, MI
I am working on a script that will read the name of a java app and rename the file to the name of the app. This is an effort to organize about 2500 programs. I know how to read the name of the program, but the command I'm using to rename the file puts a '?' just before the extension. Take a look:
Code:
mv sample.jar `awk '/MIDlet-Name:/ {print $2}' MANIFEST.MF`.jar


This turns sample.jar into 'name of app'?.jar

So what do I need to do to get rid of the '?' ? This is the first shell script I've ever written in my life, so bear with me here... :D


Top
 Profile YIM  
 PostPosted: Wed Nov 15, 2006 2:07 am   

Joined: Wed Nov 15, 2006 1:21 am
Posts: 3
Location: Grand Blanc, MI
Nevermind. I solved my problem with:
Code:
mv sample.jar `awk '/^MIDlet-Name:/ {print substr($2,1,length($2)-1)}' MANIFEST.MF`.jar


Apparently the way I had it was returning '\n' at the end, which was converted to '?' in the renaming process. If anyone knows a better or more efficient/faster way to do this, please share!


Top
 Profile YIM  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP