Script to slightly alter folder/name.

Come up with a useful post-processing script? Share it here!
Post Reply
stergil
Newbie
Newbie
Posts: 23
Joined: August 26th, 2010, 10:22 pm

Script to slightly alter folder/name.

Post by stergil »

I'm struggling with automatically renaming a regular download.

Both the folder it gets moved to as well as the filename needs to use "&" instead of "and".

I'm using CentOS Linux and have a filter setup for the download already to trigger a script, I'm just not able to make the script operate as desired.

Any help is appreciated
User avatar
sander
Release Testers
Release Testers
Posts: 9115
Joined: January 22nd, 2008, 2:22 pm

Re: Script to slightly alter folder/name.

Post by sander »

If you would post the script and tell what works and what not, maybe others can help.
exussum
Jr. Member
Jr. Member
Posts: 79
Joined: November 18th, 2010, 2:51 am

Re: Script to slightly alter folder/name.

Post by exussum »

rename -n-v 's/and/&/' *

should work
stergil
Newbie
Newbie
Posts: 23
Joined: August 26th, 2010, 10:22 pm

Re: Script to slightly alter folder/name.

Post by stergil »

exussum wrote:rename -n-v 's/and/&/' *

should work
Thanks for the quick response! It looks like that rename command will work real well on the file.

However, how do I get it moved to the proper folder?

So for example:

Code: Select all

/files/Some and Show/Season 2/Some.and.Show.S02E04.avi
needs to be moved and renamed to:

Code: Select all

/files/Some & Show/Season 2/Some.&.Show.S02E04.avi
Looks like I can easily get to the extract path with $1 & rename the file, but how do I figure out what season folder the file needs to be moved to?

Or am I over-thinking it, is there an easier way?
User avatar
sander
Release Testers
Release Testers
Posts: 9115
Joined: January 22nd, 2008, 2:22 pm

Re: Script to slightly alter folder/name.

Post by sander »

If

Code: Select all

rename -n-v 's/and/&/' *
works, how about

Code: Select all

rename -n-v 's/and/&/' *
rename -n-v 's/and/&/' */*
rename -n-v 's/and/&/' */*/*
So: going three levels deep. I have not tested this, but it looks logical to me.
Post Reply