Gentoo Archives: gentoo-user

From: Francisco Ares <frares@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Changing names of LOTS of files, adding to them actually.
Date: Thu, 01 Dec 2011 02:21:58
Message-Id: CAHH9eM6cb_JwocfBpW=HpTB9KfvPKn0n9AFbmB--OTKAh=SiuA@mail.gmail.com
In Reply to: [gentoo-user] Changing names of LOTS of files, adding to them actually. by Dale
1 I use the following script to remove parts of downloaded videos, I guess it
2 wont't be hard to figure out how to change it to your needs. It also
3 creates a text file with the name of the file and, expecting it to be a
4 video file, it uses midentify, part of the mplayer package, to read the
5 duration of the video in a form that LibreOffice is able to import directly.
6
7
8
9 #! /bin/bash
10 for i in *unwantedString.??? # it can be a MP4 or a FLV
11 do
12 if [ "$i" != "*unwantedString.???" ] # this checks if the list is empty
13 then
14 j=`echo $i | sed s/\ \-\ unwantedString//`
15 # echo $j
16 mv "$i" "$j"
17 fi
18 done
19
20 for i in *.mp4 *.flv # this removes duplicated file extension
21 do
22 if [ "$i" != "*.mp4" ] && [ "$i" != "*.flv" ]
23 then
24 j=`echo $i | sed -e s/\.mp4\.mp4/\.mp4/ -e s/\.flv\.flv/\.flv/`
25 # echo $j
26 if [ "$i" != "$j" ]
27 then
28 mv "$i" "$j"
29 fi
30 fi
31 done
32
33 if [ -e contents.txt ]
34 then
35 rm contents.txt
36 fi
37 for i in *.mp4 *.flv
38 do
39 if [ "$i" != "*.mp4" ] && [ "$i" != "*.flv" ]
40 then
41 j=`midentify "$i" | grep ID_LENGTH | cut -d\= -f 2`
42 k=`echo $i | sed -e s/\.mp4//g -e s/\.flv//g`
43 echo -e $k \\t 00:00:`echo $j | cut -d\. -f1`,`echo $j | cut -d \.
44 -f2` >> contents.txt
45 fi
46 done
47
48 Hope it helps
49 Francisco
50
51
52
53
54 On Wed, Nov 30, 2011 at 11:49 PM, Dale <rdalek1967@×××××.com> wrote:
55
56 > Greets,
57 >
58 > I ran into a problem. I been downloading a lot of TV shows. I forgot to
59 > put a sort of important part in the names. This is what I have with the
60 > full path:
61 >
62 > /data/Movies/TV_Series/Person of Interest/Season 1, Episode 1 - Pilot.mp4
63 >
64 > This is what I need it to be:
65 >
66 > /data/Movies/TV_Series/Person of Interest/Person of Interest - Season 1,
67 > Episode 1 - Pilot.mp4
68 >
69 > Basically, I need to add the name of the show to the name of the file.
70 > They will all be added to the front of the names. They also almost all
71 > contain spaces, which means some fancy footwork with the \.
72 >
73 > Is there a way to do this? I have room to copy them to another directory
74 > if needed. I would sort of actually prefer it that way since if it messes
75 > up, I got the originals at least.
76 >
77 > Sorry I'm not real good at gawk, sed and all those things. I suspect
78 > those will be used tho. I am familiar with | and grep tho. ;-)
79 >
80 > Thoughts?
81 >
82 > Dale
83 >
84 > :-) :-)
85 >
86 > --
87 > I am only responsible for what I said ... Not for what you understood or
88 > how you interpreted my words!
89 >
90 >
91 >
92
93
94 --
95 "If you have an apple and I have an apple and we exchange apples then you
96 and I will still each have one apple. But if you have an idea and I have
97 one idea and we exchange these ideas, then each of us will have two ideas."
98 - George Bernard Shaw

Replies

Subject Author
Re: [gentoo-user] Changing names of LOTS of files, adding to them actually. Francisco Ares <frares@×××××.com>