FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 12-01-2011, 12:49 AM
Dale
 
Default Changing names of LOTS of files, adding to them actually.

Greets,

I ran into a problem. I been downloading a lot of TV shows. I forgot
to put a sort of important part in the names. This is what I have with
the full path:


/data/Movies/TV_Series/Person of Interest/Season 1, Episode 1 - Pilot.mp4

This is what I need it to be:

/data/Movies/TV_Series/Person of Interest/Person of Interest - Season 1,
Episode 1 - Pilot.mp4


Basically, I need to add the name of the show to the name of the file.
They will all be added to the front of the names. They also almost all
contain spaces, which means some fancy footwork with the .


Is there a way to do this? I have room to copy them to another
directory if needed. I would sort of actually prefer it that way since
if it messes up, I got the originals at least.


Sorry I'm not real good at gawk, sed and all those things. I suspect
those will be used tho. I am familiar with | and grep tho. ;-)


Thoughts?

Dale

:-) :-)

--
I am only responsible for what I said ... Not for what you understood or how you interpreted my words!
 
Old 12-01-2011, 01:18 AM
Frank Steinmetzger
 
Default Changing names of LOTS of files, adding to them actually.

On Wed, Nov 30, 2011 at 07:49:26PM -0600, Dale wrote:

> I ran into a problem. I been downloading a lot of TV shows. I forgot
> to put a sort of important part in the names. This is what I have with
> the full path:
>
> /data/Movies/TV_Series/Person of Interest/Season 1, Episode 1 - Pilot.mp4
>
> This is what I need it to be:
>
> /data/Movies/TV_Series/Person of Interest/Person of Interest - Season 1,
> Episode 1 - Pilot.mp4
>
> Basically, I need to add the name of the show to the name of the file.
> They will all be added to the front of the names. They also almost all
> contain spaces, which means some fancy footwork with the .
>
> Is there a way to do this? I have room to copy them to another
> directory if needed. I would sort of actually prefer it that way since
> if it messes up, I got the originals at least.
>
> Sorry I'm not real good at gawk, sed and all those things. I suspect
> those will be used tho. I am familiar with | and grep tho. ;-)
>
> Thoughts?

I can’t remember right now what graphical environment you use, but for KDE
there is KRename. But if you want it quick and efficient, I suggest
renameutils. You give it a list of files and it opens $EDITOR containing two
columns with the list. The first is the old name, and in the second you can
enter the new name.

It’s basically a mass renamer for the console, powered by your favorite
features of your favorite editor. With the recursive flag -R you can even do
what you want for many dirs at once and then insert the Series name using
search and replace with regular expressions.

But your particular example could be done simply with:

cd "/data/Movies/TV_Series/Person of Interest"
for i in *.mp4; do mv -n "$i" "Person of Interest - $i"; done
--
Gruß | Greetings | Qapla'
I forbid any use of my email addresses with Facebook services.

The advantage of smartness is that one can pretend to be stupid.
The opposite is far more difficult.
 
Old 12-01-2011, 01:19 AM
Francisco Ares
 
Default Changing names of LOTS of files, adding to them actually.

I use the following script to remove parts of downloaded videos, I guess it wont't be hard to figure out how to change it to your needs. It also creates a text file with the name of the file and, expecting it to be a video file, it uses midentify, part of the mplayer package, to read the duration of the video in a form that LibreOffice is able to import directly.




#! /bin/bash
for i in *unwantedString.??? * # it can be a MP4 or a FLV
do
* *if [ "$i" != "*unwantedString.???" ] * # this checks if the list is empty

* *then
* * * *j=`echo $i | sed s/ - unwantedString//`
* * * *# echo $j
* * * *mv "$i" "$j"
* *fi
done


for i in *.mp4 *.flv *# this removes duplicated file extension
do
* *if [ "$i" != "*.mp4" ] && [ "$i" != "*.flv" ]
* *then
* * * j=`echo $i | sed -e s/.mp4.mp4/.mp4/ -e s/.flv.flv/.flv/`

* * * # echo $j
* * * if [ "$i" != "$j" ]
* * * then
* * * * *mv "$i" "$j"
* * * fi
* *fi

done
if [ -e contents.txt ]
then
* *rm contents.txt
fifor i in *.mp4 *.flv
do
* *if [ "$i" != "*.mp4" ] && [ "$i" != "*.flv" ]

* *then
* * * j=`midentify "$i" | grep ID_LENGTH | cut -d= -f 2`
* * * k=`echo $i | sed -e s/.mp4//g -e s/.flv//g`
* * * echo -e $k 00:00:`echo $j | cut -d. -f1`,`echo $j | cut -d . -f2` >> contents.txt

* *fi
done
Hope it helpsFrancisco



On Wed, Nov 30, 2011 at 11:49 PM, Dale <rdalek1967@gmail.com> wrote:

Greets,



I ran into a problem. *I been downloading a lot of TV shows. *I forgot to put a sort of important part in the names. *This is what I have with the full path:



/data/Movies/TV_Series/Person of Interest/Season 1, Episode 1 - Pilot.mp4



This is what I need it to be:



/data/Movies/TV_Series/Person of Interest/Person of Interest - Season 1, Episode 1 - Pilot.mp4



Basically, I need to add the name of the show to the name of the file. *They will all be added to the front of the names. *They also almost all contain spaces, which means some fancy footwork with the .



Is there a way to do this? *I have room to copy them to another directory if needed. *I would sort of actually prefer it that way since if it messes up, I got the originals at least.



Sorry I'm not real good at gawk, sed and all those things. *I suspect those will be used tho. *I am familiar with | and grep tho. *;-)



Thoughts?



Dale



:-) *:-)



--

I am only responsible for what I said ... Not for what you understood or how you interpreted my words!







--
"If you have an apple and I have an apple and we exchange apples then you and I will still each have one apple. But if you have an idea and I have one idea and we exchange these ideas, then each of us will have two ideas." - George Bernard Shaw
 
Old 12-01-2011, 01:22 AM
Pandu Poluan
 
Default Changing names of LOTS of files, adding to them actually.

On Dec 1, 2011 8:54 AM, "Dale" <rdalek1967@gmail.com> wrote:

>

> Greets,

>

> I ran into a problem. *I been downloading a lot of TV shows. *I forgot to put a sort of important part in the names. *This is what I have with the full path:

>

> /data/Movies/TV_Series/Person of Interest/Season 1, Episode 1 - Pilot.mp4

>

> This is what I need it to be:

>

> /data/Movies/TV_Series/Person of Interest/Person of Interest - Season 1, Episode 1 - Pilot.mp4

>

> Basically, I need to add the name of the show to the name of the file. *They will all be added to the front of the names. *They also almost all contain spaces, which means some fancy footwork with the .

>

> Is there a way to do this? *I have room to copy them to another directory if needed. *I would sort of actually prefer it that way since if it messes up, I got the originals at least.

>

> Sorry I'm not real good at gawk, sed and all those things. *I suspect those will be used tho. *I am familiar with | and grep tho. *;-)

>

> Thoughts?

>


'find' and 'mv' should do the job.* With some help from 'dirname' and 'basename'.* E. g.


find $PATHTOMOVIES -name "*. mp4" -exec mv "{}" "$(dirname {})/$(basename $(dirname {})) - $(basename {})"


Not tested, though. So you'd better use 'echo' instead of 'mv' for a dry run.


Rgds,
 
Old 12-01-2011, 01:22 AM
 
Default Changing names of LOTS of files, adding to them actually.

Take a look at rename, Dale.

Its usage syntax wasn't obvious to me at first but after using it a few times I got the hang of it.

Bill

--
Sent from my HP TouchPad which is really braindead when trying not to toppost.On Nov 30, 2011 5:50 PM, Dale <rdalek1967@gmail.com> wrote:
Greets,



I ran into a problem. I been downloading a lot of TV shows. I forgot

to put a sort of important part in the names. This is what I have with

the full path:



/data/Movies/TV_Series/Person of Interest/Season 1, Episode 1 - Pilot.mp4



This is what I need it to be:



/data/Movies/TV_Series/Person of Interest/Person of Interest - Season 1,

Episode 1 - Pilot.mp4



Basically, I need to add the name of the show to the name of the file.

They will all be added to the front of the names. They also almost all

contain spaces, which means some fancy footwork with the .



Is there a way to do this? I have room to copy them to another

directory if needed. I would sort of actually prefer it that way since

if it messes up, I got the originals at least.



Sorry I'm not real good at gawk, sed and all those things. I suspect

those will be used tho. I am familiar with | and grep tho. ;-)



Thoughts?



Dale



:-) :-)



--

I am only responsible for what I said ... Not for what you understood or how you interpreted my words!
 
Old 12-01-2011, 01:23 AM
Francisco Ares
 
Default Changing names of LOTS of files, adding to them actually.

Sorry, did not read your message to the end.

So the sixth line on that script, on your case, instead of:
* * **j=`echo $i | sed s/ - unwantedString//`

should be:
* * * j="Person of Interest - "$i
I guess that's it. You will have to open a console at the directory where your movies are in.

Francisco


On Thu, Dec 1, 2011 at 12:19 AM, Francisco Ares <frares@gmail.com> wrote:

I use the following script to remove parts of downloaded videos, I guess it wont't be hard to figure out how to change it to your needs. It also creates a text file with the name of the file and, expecting it to be a video file, it uses midentify, part of the mplayer package, to read the duration of the video in a form that LibreOffice is able to import directly.





#! /bin/bash
for i in *unwantedString.??? * # it can be a MP4 or a FLV
do
* *if [ "$i" != "*unwantedString.???" ] * # this checks if the list is empty


* *then
* * * *j=`echo $i | sed s/ - unwantedString//`
* * * *# echo $j
* * * *mv "$i" "$j"
* *fi
done



for i in *.mp4 *.flv *# this removes duplicated file extension
do
* *if [ "$i" != "*.mp4" ] && [ "$i" != "*.flv" ]
* *then
* * * j=`echo $i | sed -e s/.mp4.mp4/.mp4/ -e s/.flv.flv/.flv/`


* * * # echo $j
* * * if [ "$i" != "$j" ]
* * * then
* * * * *mv "$i" "$j"
* * * fi
* *fi


done
if [ -e contents.txt ]
then
* *rm contents.txt
fifor i in *.mp4 *.flv
do
* *if [ "$i" != "*.mp4" ] && [ "$i" != "*.flv" ]


* *then
* * * j=`midentify "$i" | grep ID_LENGTH | cut -d= -f 2`
* * * k=`echo $i | sed -e s/.mp4//g -e s/.flv//g`
* * * echo -e $k 00:00:`echo $j | cut -d. -f1`,`echo $j | cut -d . -f2` >> contents.txt


* *fi
done
Hope it helpsFrancisco



On Wed, Nov 30, 2011 at 11:49 PM, Dale <rdalek1967@gmail.com> wrote:


Greets,



I ran into a problem. *I been downloading a lot of TV shows. *I forgot to put a sort of important part in the names. *This is what I have with the full path:



/data/Movies/TV_Series/Person of Interest/Season 1, Episode 1 - Pilot.mp4



This is what I need it to be:



/data/Movies/TV_Series/Person of Interest/Person of Interest - Season 1, Episode 1 - Pilot.mp4



Basically, I need to add the name of the show to the name of the file. *They will all be added to the front of the names. *They also almost all contain spaces, which means some fancy footwork with the .



Is there a way to do this? *I have room to copy them to another directory if needed. *I would sort of actually prefer it that way since if it messes up, I got the originals at least.



Sorry I'm not real good at gawk, sed and all those things. *I suspect those will be used tho. *I am familiar with | and grep tho. *;-)



Thoughts?



Dale



:-) *:-)



--

I am only responsible for what I said ... Not for what you understood or how you interpreted my words!







--
"If you have an apple and I have an apple and we exchange apples then you and I will still each have one apple. But if you have an idea and I have one idea and we exchange these ideas, then each of us will have two ideas." - George Bernard Shaw





--
"If you have an apple and I have an apple and we exchange apples then you and I will still each have one apple. But if you have an idea and I have one idea and we exchange these ideas, then each of us will have two ideas." - George Bernard Shaw
 
Old 12-01-2011, 01:29 AM
Pandu Poluan
 
Default Changing names of LOTS of files, adding to them actually.

On Dec 1, 2011 9:22 AM, "Pandu Poluan" <pandu@poluan.info> wrote:

>

>

> On Dec 1, 2011 8:54 AM, "Dale" <rdalek1967@gmail.com> wrote:

> >

> > Greets,

> >

> > I ran into a problem. *I been downloading a lot of TV shows. *I forgot to put a sort of important part in the names. *This is what I have with the full path:

> >

> > /data/Movies/TV_Series/Person of Interest/Season 1, Episode 1 - Pilot.mp4

> >

> > This is what I need it to be:

> >

> > /data/Movies/TV_Series/Person of Interest/Person of Interest - Season 1, Episode 1 - Pilot.mp4

> >

> > Basically, I need to add the name of the show to the name of the file. *They will all be added to the front of the names. *They also almost all contain spaces, which means some fancy footwork with the .

> >

> > Is there a way to do this? *I have room to copy them to another directory if needed. *I would sort of actually prefer it that way since if it messes up, I got the originals at least.

> >

> > Sorry I'm not real good at gawk, sed and all those things. *I suspect those will be used tho. *I am familiar with | and grep tho. *;-)

> >

> > Thoughts?

> >

>

> 'find' and 'mv' should do the job.* With some help from 'dirname' and 'basename'.* E. g.

>

> find $PATHTOMOVIES -name "*. mp4" -exec mv "{}" "$(dirname {})/$(basename $(dirname {})) - $(basename {})"

>

> Not tested, though. So you'd better use 'echo' instead of 'mv' for a dry run.

>


Whoopsies. I certainly must've made some mistakes with the escaping there...


Oh well,* just write a short script containing this:


mv "$1" "$(dirname $1)/$(basename $(dirname $1)) - $(basename $1)"


and feed that script (after chmod +x,* of course) to the -exec part of find, e.g.


find ... -exec scriptname.sh {} ;


Rgds,
 
Old 12-01-2011, 01:46 AM
Dale
 
Default Changing names of LOTS of files, adding to them actually.

Frank Steinmetzger wrote:

On Wed, Nov 30, 2011 at 07:49:26PM -0600, Dale wrote:


I ran into a problem. I been downloading a lot of TV shows. I forgot
to put a sort of important part in the names. This is what I have with
the full path:

/data/Movies/TV_Series/Person of Interest/Season 1, Episode 1 - Pilot.mp4

This is what I need it to be:

/data/Movies/TV_Series/Person of Interest/Person of Interest - Season 1,
Episode 1 - Pilot.mp4

Basically, I need to add the name of the show to the name of the file.
They will all be added to the front of the names. They also almost all
contain spaces, which means some fancy footwork with the .

Is there a way to do this? I have room to copy them to another
directory if needed. I would sort of actually prefer it that way since
if it messes up, I got the originals at least.

Sorry I'm not real good at gawk, sed and all those things. I suspect
those will be used tho. I am familiar with | and grep tho. ;-)

Thoughts?

I can’t remember right now what graphical environment you use, but for KDE
there is KRename. But if you want it quick and efficient, I suggest
renameutils. You give it a list of files and it opens $EDITOR containing two
columns with the list. The first is the old name, and in the second you can
enter the new name.

It’s basically a mass renamer for the console, powered by your favorite
features of your favorite editor. With the recursive flag -R you can even do
what you want for many dirs at once and then insert the Series name using
search and replace with regular expressions.

But your particular example could be done simply with:

cd "/data/Movies/TV_Series/Person of Interest"
for i in *.mp4; do mv -n "$i" "Person of Interest - $i"; done


Oh heck yea. Krename did a wonderful job. It renamed them in place. I
tested it on a small directory with just a few files at first. This is
cool. I didn't know KDE had this and it wasn't installed either.


No grep, gawk or sed in the command line for this? Wow. I thought
there would be at least a couple of those in there. lol


Thanks for the info. I didn't even think there would be a GUI for
this. o_O


Dale

:-) :-)

--
I am only responsible for what I said ... Not for what you understood or how you interpreted my words!
 
Old 12-01-2011, 02:23 AM
Frank Steinmetzger
 
Default Changing names of LOTS of files, adding to them actually.

On Wed, Nov 30, 2011 at 06:22:18PM -0800, bill.longman@gmail.com wrote:

> […]
> Sent from my HP TouchPad which is really braindead when trying not to toppost.

…and at providing a plaintext version. Stupid modern fingery-touchy-swipey
gloss-only facebook interface devices.

(Nothing against you or you buying it, it’s just my observation on the general
course which modern technology is taking right now)
--
Gruß | Greetings | Qapla'
I forbid any use of my email addresses with Facebook services.

The situation is hopeless, but not serious.
 
Old 12-01-2011, 03:18 AM
Dale
 
Default Changing names of LOTS of files, adding to them actually.

Dale wrote:

Greets,

I ran into a problem. I been downloading a lot of TV shows. I forgot
to put a sort of important part in the names. This is what I have
with the full path:


/data/Movies/TV_Series/Person of Interest/Season 1, Episode 1 - Pilot.mp4

This is what I need it to be:

/data/Movies/TV_Series/Person of Interest/Person of Interest - Season
1, Episode 1 - Pilot.mp4


Basically, I need to add the name of the show to the name of the
file. They will all be added to the front of the names. They also
almost all contain spaces, which means some fancy footwork with the .


Is there a way to do this? I have room to copy them to another
directory if needed. I would sort of actually prefer it that way
since if it messes up, I got the originals at least.


Sorry I'm not real good at gawk, sed and all those things. I suspect
those will be used tho. I am familiar with | and grep tho. ;-)


Thoughts?

Dale

:-) :-)




I got them all changed, about 250 or so of them. Thanks to *all* for
the replies. I got to save and review some of the command line ones
too. May learn something. Sort of reminds me of my old Vic-20. O_O


Thanks much.

Dale

:-) :-)

--
I am only responsible for what I said ... Not for what you understood or how you interpreted my words!
 

Thread Tools




All times are GMT. The time now is 07:14 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org