Register
It is currently Wed Apr 16, 2014 3:53 pm

Add extensions to extensionless files


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Sun Aug 31, 2008 7:54 am   

Joined: Sun Apr 22, 2007 5:16 am
Posts: 7
I need to give a lot (batch rename) of files the extension .flv.

I have a lot of files that look like this,FlashHKUECB and FlashHocJyj,etc.
These files were all moved to a test directory from /tmp.
They do not have the extension .flv.

If I give them the extension .flv one at a time,then they play fine without using "open with".
But there are LOTS of them.

I've played around with bash scripts that can rename files,but I've always had something for the script to "find" and then change to something else.
This has me baffled though.

If I wanted to do something like "for f in *.flv*;",I would be looking for .flv.
In this case,there is no .flv to look for.
I want to add .flv to files with no common pattern,other than most of them have a filename that begins with "Flash".


Top
 Profile  
 PostPosted: Sun Aug 31, 2008 1:34 pm   
User avatar

Joined: Sun Apr 13, 2008 4:05 am
Posts: 37
Location: /dev/random
Code:
#!/bin/bash
#secureflvrename.sh
#author: myownshadow

for file in   `file * | grep "Macromedia Flash Video"| sed "s/:*Macromedia Flash Video//" | sed "s/://"`
do 
   mv $file  `basename $file`.flv
done


this script checks filetype disregarding filename, and renaming the real flv files in current directory, u can change "*" with $1 to give an argument target.
Quote:
so it seems im not fine with sed, can someone pull together two sed sentences?


Top
 Profile  
 PostPosted: Sun Aug 31, 2008 7:19 pm   

Joined: Sun Apr 22, 2007 5:16 am
Posts: 7
myownshadow wrote:
Code:
#!/bin/bash
#secureflvrename.sh
#author: myownshadow

for file in   `file * | grep "Macromedia Flash Video"| sed "s/:*Macromedia Flash Video//" | sed "s/://"`
do 
   mv $file  `basename $file`.flv
done


this script checks filetype disregarding filename, and renaming the real flv files in current directory, u can change "*" with $1 to give an argument target.
Quote:
so it seems im not fine with sed, can someone pull together two sed sentences?


Thank You.
This script worked excellant.
Now that I have a script that actually works,I will attempt to learn how it works.
Looks like a lot going on with it.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 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