Jump to content

Running Command for Files Where Part of Name Change Daily


BzowK
 Share

Recommended Posts

Hey Guys - 

I'm an AutoIT newbie as I can barely make the learning scripts and need some assistance, please.  Here's what I'm trying to do...

About 3-4 times a week, I have a script which downloads 5 mp3 files to a folder.  After download, I manually combine these mp3 files into a single file which I move to a new folder .  I've been able to automate the download part of it, but am trying to find a way to script the merging of the files.  
 
I've already found a command line utility which will join them - mp3wrap - which I've tested successfully. WHen specifying the output file name in the command, I could just add the path I move it to which should take care of that part of it. Basically, I just need to know how to put it all together.  Below are all the variables which would be involved:
 
Format of file names of all 5 files
Note: The date in each file will always be the same as they date they are downloaded
  • show_128k_12-01-2014_part001of05.mp3
  • show_128k_12-01-2014_part002of05.mp3
  • show_128k_12-01-2014_part003of05.mp3
  • show_128k_12-01-2014_part004of05.mp3
  • show_128k_12-01-2014_part005of05.mp3
Command line string which would be used to join the above files using mp3wrap
Format: mp3wrap OUTPUT.mp3 file1.mp3 file2.mp3...
mp3wrap D:\CombinedShows\show_128_12-01-2014_combined.mp3  show_128k_12-01-2014_part001of05.mp3 show_128k_12-01-2014_part002of05.mp3 show_128k_12-01-2014_part003of05.mp3 show_128k_12-01-2014_part004of05.mp3 show_128k_12-01-2014_part005of05.mp3
 
Ideas
Even putting this into a batch file and running via Windows Tasks would be simple, but the date in each file name changes daily.  Therefore, I'd think I'd need to make a script doing one of the two things:
  • Use wildcards for the date in the file name in the script and make sure that they are the only files in the folder (that shows from other dates aren't in the same folder.
  • Since the files being downloaded will always be downloaded on the same date as what's in the file name, I could instead use some type of variable which will look for files with the current date in the same format.

Any suggestions for how to format a script and/or what functions to use to get this to work well?

Thanks for your help!

Edited by BzowK
Link to comment
Share on other sites

_FileListToArray is what you should be looking at.

Something like...

$aList = _FileListToArray("Path_To_Folder", "*.mp3", 1)
Run("mp3wrap OUTPUT.mp3 " & $aList[1] & " " & $aList[2] & " " & $aList[3] & " " & $aList[4] & " " & $aList[5])

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Thanks for your quick reply - Couple of questions, please...

1. There are obviously 5 parts which must be in order.  Will using something like that guarantee that they will be combined in order each time?  Basicilly, will FileListToArray list them in numerical order 100% of the time?

2. I do want this to be automated so am wanting the OUTPUT file name to have the same date as the combined files.  What's the best way to do this?  Set a variable for the day's date (would prefer grabbing from input files but if must get it from OS, that's ok, i guess) then append it to to OUTPUT.mp3 in the "Run" line?

3. If setting a variable for the date, would it then be easy to make it not just list *.mp3 in folder, but all the ones which include the date variable in the same format as the source?  Example:  If variable was set to "12-01-2014", use "*{variable}*.mp3" instead of "*.mp3"

Hope that makes sense.  Thanks!

Link to comment
Share on other sites

Also...

I'm trying to use it, but it won't work.  Probably a newb issue :) I created a new script, pasted your code, then changed the path as below:

$aList = _FileListToArray("D:\test2", "*.mp3", 1)
Run("mp3wrap D:\Test3.mp3 " & $aList[1] & " " & $aList[2] & " " & $aList[3] & " " & $aList[4] & " " & $aList[5])

5 mp3s and mp3wrap.exe exist in that path (D:test2.)  When I run it, I get 

AutoIT Error

$aList = _FileListToArray("D:test2", "*.mp3", 1)

$aList = ^ ERROR

Error: Unknown function name.

What am i doing wrong?  Thanks!

Link to comment
Share on other sites

The  _FileListToArray component of AutoIt has an extra internal UDF that it must process to be able to do its work.

Put at the top of your script

#include <File.au3>

And this will tell the script to include that extra component so that your script will run properly

Link to comment
Share on other sites

?

#include <File.au3>
#Include <Array.au3>

$folder = @scriptdir & "\test\"
$date = "12-01-2014"   ; @MDAY & "-" & @MON & "-" & @YEAR  format dd-mm-yyyy
$aList = _FileListToArray($folder, "*" & $date & "*.mp3", 1)
 _ArrayDisplay($aList)
$input = ""
For $i = 1 to $aList[0]
   $input &= " " & $aList[$i]
Next
$output = StringRegExpReplace($aList[1], '(part.*)', "combined.mp3")
Msgbox(0,"", "mp3wrap " & $folder & $output & $input)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...