LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 11-19-2008, 05:52 PM   #1
ckent
Member
 
Registered: Jan 2007
Distribution: Ubuntu
Posts: 59

Rep: Reputation: 15
how to automatically rename files


I'm looking for a way to automatically rename (and possibly move) files. I have a server that downloads my favourite tv shows and I would like the files that show up in the download folder to be renamed (based on set rules). Is this possible? Do I have to write a script or is there a program that will already do this?
 
Old 11-19-2008, 06:04 PM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Yes it's possible, and I suspect you need to write a script.

What are the rules?
 
Old 11-19-2008, 06:39 PM   #3
ckent
Member
 
Registered: Jan 2007
Distribution: Ubuntu
Posts: 59

Original Poster
Rep: Reputation: 15
i want it to rename the file (which will look like Title.Title.S##E##.hdtv.eztv-lol.avi) to be Title Title ##x##.avi
 
Old 11-19-2008, 06:41 PM   #4
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
That's pretty simple. Are you using a script to download the files?
 
Old 11-20-2008, 02:10 AM   #5
unihiekka
Member
 
Registered: Aug 2005
Distribution: SuSE Linux / Scientific Linux / [K|X]ubuntu
Posts: 273

Rep: Reputation: 32
There is a bulk rename app that you can download through synaptic. Just look for bulk rename and you'll find it.
 
Old 11-20-2008, 11:18 PM   #6
ckent
Member
 
Registered: Jan 2007
Distribution: Ubuntu
Posts: 59

Original Poster
Rep: Reputation: 15
will that automatically rename the files as they show up though?
 
Old 11-20-2008, 11:50 PM   #7
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Again, how are you downloading the files?
 
Old 11-21-2008, 11:32 PM   #8
ckent
Member
 
Registered: Jan 2007
Distribution: Ubuntu
Posts: 59

Original Poster
Rep: Reputation: 15
using miro to download the bittorrents from an rss feed
 
Old 11-22-2008, 02:48 AM   #9
unihiekka
Member
 
Registered: Aug 2005
Distribution: SuSE Linux / Scientific Linux / [K|X]ubuntu
Posts: 273

Rep: Reputation: 32
Quote:
will that automatically rename the files as they show up though?
It's not psychic, so it won't do that automatically! But if you say that you want to replace a certain string of (special) characters in lots of files with something else, then it works fine.

Or you could legally buy the DVDs of your favourite TV series and then watch them on you TV. No renaming there!

Last edited by unihiekka; 11-22-2008 at 02:49 AM.
 
Old 11-22-2008, 04:17 AM   #10
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
For the renaming, I'd use a script along the lines of
Code:
cd /path/to/files
for filename in *"hdtv.eztv"* ;do
  newfile=$(echo $filename | sed -e 's/\(.*\)\.\(.*\)\.S\(..\)E\(..\)\.hdtv\.eztv\-lol\.avi/\1 \2 \3x\4\.avi/')
  echo  $filename "|" $newfile
#  mv $filename $newfile
done
(note the test mode of just echoing potential changes - comment that out and uncomment the "mv" if it works)

In terms of calling the script, you could run this regularly from a cron job (every 15 minutes for example), or if you are keen, there is a program called incron that is similar to cron, but rather than watching time, incron watches directories for changes. In other words, incron can trigger scripts when files are created in directories.

Cron wold be simpler, but let us know if you'd prefer to try incron.
 
Old 11-22-2008, 11:27 PM   #11
ckent
Member
 
Registered: Jan 2007
Distribution: Ubuntu
Posts: 59

Original Poster
Rep: Reputation: 15
thanks billymayday i will try that out. i think my idea was something like incron where any changes would trigger the event, but cron should work fine. i mean it's not like i need it to be instant (or even psychic).

have a great day and thanks again for your help!
 
Old 11-22-2008, 11:43 PM   #12
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
No probs - just remember to come back and tell us what worked, how it went, etc.
 
Old 11-24-2008, 05:19 AM   #13
greatquizzard
Member
 
Registered: Mar 2006
Location: Singapore
Distribution: Ubuntu 10.10
Posts: 83

Rep: Reputation: 16
Xfce's Thunar file manager includes a built-in rule-based file renaming utility. Particularly handy because it gives you a preview of what your renaming rule will do. You could either use regular expressions or do the renaming in stages (i.e., renaming the beginning part first, then the end, etc). You don't need to install complete Xfce, just Thunar.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to rename files bkcreddy17 Programming 7 09-14-2008 09:22 AM
rename files linux2man Linux - General 8 02-03-2007 05:26 AM
automatically rename file uthinkicare Programming 5 12-07-2006 03:19 AM
program to rename mp3 automatically? buffed317 Linux - Software 1 02-22-2005 07:48 PM
Can not rename files. Maximus2000 Linux - General 0 04-22-2004 01:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 09:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration