renaming of files

hi,

i work for a radio stationand we have a piece of sofware that records files into mp3 and in the following convention 20110429190010.mp3 (so it gives the date and time)

i was wondering is there anyway to get a script to a) rename the file based on the time? and b) copy the file to somewhere else?

So for instance it sees this file with 1900 which corresponds to a show called part mix, could i get any file that shows 1900 to be renamed to partymix and copied to a location say c:\mp3 ?

Thanks as always
jonathanduane2010Asked:
Who is Participating?
 
Bill PrewCommented:
Yes, once you try it from the command line and verify that it is doing the right things with the right files, remove the ECHOs.

~bp
0
 
Bill PrewCommented:
Is the format of the current filename YYYYMMDDhhmmss ?

Do the time stamps vary on each file, and if so will a range check be needed, meaning that any files bewtween 1900 and 2000 should be associated with say "part mix" show?

It sounds like what you need could be done, but we would need a cross reference of the times that you want to copy to the show name to associate that with.

It would be helpful to see a larger sample of the filenames too.

~bp
0
 
jonathanduane2010Author Commented:
yes the software is called aircheck it records file every hour and then names them YYYYMMDDhhmmss

well if i could get a script and then could i just change it for every hour ? just swap out 1900 for 2000 and "partymix" for another associated show?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Patrick MatthewsCommented:
jonathanduane2010,

Some questions:

1) How much does your schedule vary?  For example, I would think it possible that your schedule is more or less the same Mon-Fri, but then I would expect that Sat and/or Sun could be quite different, thus making a rule such as "if it's 1900 it must be Party Mix" potentially problematic

2) All broadcast entities change their schedules over time.  How frequently does your station change its schedule?  And what about one-off specials?  Having some sort of scheduling database for the script to key off of is probably advisable.

Patrick
0
 
Bill PrewCommented:
Also, is it possible to have more than one file with the same hhmm (hour/minute) value?  Either because there were multiple MP3's that hour, or from multiple days?  If so, how should these be handled?

~bp
0
 
jonathanduane2010Author Commented:
the point why i am trying to this is because we want to create files on our website for a "Listen Back Feature" and luckily enough the shows we are uploading only happen once a week.

So "partymix" is actually a 3 hour show from 1900-2200 so there shouldnt be any confliction and billprew no only one mp3 gets recorded per hour.
0
 
Bill PrewCommented:
Here's a quick BAT file approach.  Save this as a BAT file, and then run like this:

EE27026289.bat "1900" "partymix"

or

EE27026289.bat

in the first case the timestamp and showname will be gotten from the command line.  If they are not provided as in the second example then the script will prompt for them.

@echo off

REM Define source and destination folders
set BaseDir=c:\temp\base
set DestDir=c:\temp\dest

REM Get timestamp to process from command line, or prompt if none provided
if "%~1"=="" (
  set /p "HHMM=Please specify timestamp for file to process (HHMM): "
) else (
  set HHMM=%~1
)
if "%HHMM%"=="" (
  echo ERROR: No file timestamp specified.
  exit /b
)

REM Get showname from command line, or prompt if none provided
if "%~2"=="" (
  set /p "SHOW=Please specify showname to rename file to: "
) else (
  set SHOW=%~2
)
if "%SHOW%"=="" (
  echo ERROR: No showname specified.
  exit /b
)

REM Find files for this HHMM and copy and rename
for %%A in ("%BaseDir%\????????%HHMM%??.mp3") do (
  ECHO copy "%%~A" "%DestDir%\%SHOW%.mp3"
  ECHO ren "%%~A" "%SHOW%.mp3"
)

Open in new window

~bp
0
 
Bill PrewCommented:
Also, note the "ECHO" in the front of these two line:

  ECHO copy "%%~A" "%DestDir%\%SHOW%.mp3"
  ECHO ren "%%~A" "%SHOW%.mp3"


for testing when you run the script this way, it won't actually rename of copy the files, it will just display the commands that would be executed to the screen.  This is very helpful when debugging the script, and avoids renaming the files incorrectly if there is a bug in the code.

When you are satisfied that the script should do what you need based on the output of those commands to the screen, remove the word ECHO from the front of those two lines, and run for real.

~bp
0
 
jonathanduane2010Author Commented:
thanks a mill for this guys is there anyway i could run it with no interaction as i will probably need to run them as scheduled tasks?
0
 
Bill PrewCommented:
In the case of running as a scheduled job, how will the timestamp and showname be specified?

~bp
0
 
jonathanduane2010Author Commented:
the showname will still be the same just there wiont be anybody around to run the bat file at 1900 every friday?
0
 
Bill PrewCommented:
So are you saying you just want the script to ALWAYS use 1900 and "partymix", as in:

@echo off

REM Define source and destination folders
set BaseDir=c:\temp\base
set DestDir=c:\temp\dest
set HHMM=1900
set SHOW=partymix

REM Fine files for this HHMM and copy and rename
for %%A in ("%BaseDir%\????????%HHMM%??.mp3") do (
  ECHO copy "%%~A" "%DestDir%\%SHOW%.mp3"
  ECHO ren "%%~A" "%SHOW%.mp3"
)

Open in new window

~bp
0
 
jonathanduane2010Author Commented:
yes thats brilliant!

do i still have to take out the echos?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.