topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 10:15 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Automatic file renaming - Help needed with batch files  (Read 4635 times)

mediaguycouk

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 247
    • View Profile
    • Mediaguy
    • Donate to Member
Automatic file renaming - Help needed with batch files
« on: December 11, 2007, 03:34 AM »
Hi helpful and knowledgeable people of DC.

I have a processing problem with the satellite TV that I record here for languages at the university of southampton and it is mostly due to file names.

I have 4 pieces of software

Exterity IPTV http://www.exterity....products_avedia.html
Video Redo http://www.videoredo.com/
Sorenson Squeeze http://www.sorensonm...ducts/?pageID=1#ppc2
Flash Media Server http://www.adobe.com...ts/flashmediaserver/

I'm trying to make it so I don't have to re-encode 4-8 tv news recordings each day and make things automatic.

All these processes can be made automatic with the use of scheduled tasks and batch files but the names are a problem

Exterity outputs scheduled files as namechannel day month year.mpg
Video redo outputs files as input_fixed.mpg
Sorenson outputs files as input_VP6_1Mbps_Stream.flv

Nearly all of this is fine except for the date. I would need to rename the file namechannel day month year.mpg into 'namechannel.mpg'. Once that is done I can just use the rename command.

One line summary
So is there a program that can rename files that either works by 'rename namechannel*.mpg to namechannel.mpg' or works by saying 'rename namechannel $todaysDay $todaysMonth $todaysYear'.

Many thanks for the help that anyone can give.

Graham Robinson
Learning C# - Graham Robinson

mediaguycouk

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 247
    • View Profile
    • Mediaguy
    • Donate to Member
Re: Automatic file renaming - Help needed with batch files
« Reply #1 on: December 11, 2007, 04:29 AM »
You know when you write a long post and then it gives you the inspiration to work out the answer. Well it worked for me and I'm sorry to waste anyone's time.

As it turns out Dos' rename command works fine.

rename NewsTVEiMonday*.mpg NewsTVEiMonday.mpg

Will turn
NewsTVEiMonday 10 12 07.mpg
into
NewsTVEiMonday.mpg

Making it perfect for generic batch scripts.

Graham
Learning C# - Graham Robinson

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,199
    • View Profile
    • Donate to Member
Re: Automatic file renaming - Help needed with batch files
« Reply #2 on: December 11, 2007, 04:30 AM »
So is there a program that can rename files that either works by 'rename namechannel*.mpg to namechannel.mpg' or works by saying 'rename namechannel $todaysDay $todaysMonth $todaysYear'.

Suggest you run a command prompt and DIR > DIR.DIR.  Then redirect DIR.DIR through Horst Schaeffer's LMOD List MODifier and make a temporary batch file to cut out the bits you don't want.


LMOD 1.3 Filter (c) 2002 Horst Schaeffer
Syntax: LMOD options string_with_tokens
Options:
   /Ln[-m] line [range] to select (default: first non blank line)
   /L[n]*  all lines [starting n]
   /E      include empty input lines (default: no output)
   /S..    delimiters for word extraction, instead of default (,;=)
   /B..    as /S, but excluding blank space as delimiter
   /Nn     starting line number (for token
  • ), default: /N001

Insert from source line (expression in square brackets):
 [p,l $n U|L Rn]  default []: complete line
   p,l     from position p, length l (default rest of line)
   $n      word number n ("!" for last word); optionally ñoffset
   $n:m    range of words by number (blank space will be inserted)
   U|L     convert to upper|lower case
   Rn      right aligned in output field of size n
Other tokens:
   
  •      insert CR+LF
  • [-]     omit CR+LF at end of output
       
  •      line number (digits acc. to option, default:3)
  • [=n]    tab to position n in output line
       [~n]    ASCII code n (decimal)
       [".."]  quoted char/string (use for redirection symbols)
    [/tt][/color]
Other option; run one of the renaming tools that can recognise the date strings and remove them, e.g. BKrenamer, which recognises regular expressions.

[edit]
<sigh>  I should take notice of the little warning that tells you someone else has posted while you were still typing...   :-[
[/edit]

« Last Edit: December 11, 2007, 05:56 AM by rjbull »

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: Automatic file renaming - Help needed with batch files
« Reply #3 on: December 11, 2007, 04:34 AM »
Edit: You solved it already... ;)
« Last Edit: December 11, 2007, 04:36 AM by wr975 »

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Automatic file renaming - Help needed with batch files
« Reply #4 on: December 11, 2007, 06:44 PM »
mediaguycouk, you may have solved your problem.. but just in case, i'd like to post a DC thread containing list of Renamers, maybe one would be useful to you in the future.. :)

Review of File Renamers — let's make a list