AutoHotkey Community

It is currently May 26th, 2012, 8:38 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: August 23rd, 2009, 8:12 pm 
Offline

Joined: January 27th, 2007, 8:24 pm
Posts: 30
Location: Canada
I have a video file conversion script that scans an input folder and subs, converts and sends them to an output folder and subs. The subfolders have to have the same names (used as 'channels' in a media extender box application). Im getting lost though. I dont think this will parse across drive letters. (although its working on the same drive for in/out).

Code:
{
   Loop %InPath%\*.*,0,1
         If A_LoopfileExt in %Ext%
      {
      Opdid1=""
      Opdid2=""
      Splitpath, A_Loopfilefullpath,,Filedir,,FilenameNoExt,
      RegExMatch(FileDir,"^.*\\(?=[^\\]+\\?$)",Rootpath)
      StringReplace, Foldername, Filedir, %Rootpath%,,   ; now Foldername is the folder name only
      If Filedir contains Incomplete Downloads  ; incomplete downloads is the name of the currently downloading folder
         Continue ; dumps this file and goes onto the next
      FileGetSize, ThisFileSize,, K    ; gets filesize for the current file
      If Thisfilesize = 0 ; if it has blank filesize
         Continue ; dump and get next file
      IfExist, %OutPath%\%Foldername%\%FilenameNoExt%.mpeg ; if its already been converted, then dump
         Continue ;
      FileCreateDir, %OutPath%\%Foldername%
      Runwait, ffmpeg.exe -i %A_Loopfilefullpath% %FFopt% %OutPath%\%Foldername%\%FilenameNoExt%.mpeg ,,%FFShow%
      If Errorlevel > 0
         {
         FileAppend, FFMpeg Error`n, %A_Scriptdir%\mpegmaker4miro.log
         Msgbox, FFMpeg Error !
         GoSub, Quitter
         }
etc.. just the applicable snippet here


This wont parse across drives will it ? Masking FileDir and RootPath gives me the name of the folder.. but only when its the same drive ?

I got the regex from a post on here, its probably not what I need but Im still a weakling with regex. Is there a way to get just the folder name in regex ?

Thx for any help

edit: I guess it would help to point out that InPath and OutPath are vars set in an ini file.. for example Inpath = e:\download\miro and Outpath = e:\download\videos. But of course, a user could put any In or Out path in there.. depending on their setup. So, a source file might be e:\download\miro\folderA\rssvideo.mp4 and the corresponding output should be e:\download\videos\folderA\rssvideo.mpeg

The stringreplace line would fail if the input was e:\downloads\miro\folderA\rssvideo.mp4 and the output was f:\myvideos\folderA\rssvideo.mpeg (at least I think the mask would fail..)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2009, 11:12 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
SplitPath and SplitString Aren't covering your needs?

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 25th, 2009, 1:12 am 
Offline

Joined: January 27th, 2007, 8:24 pm
Posts: 30
Location: Canada
Code:
Splitpath, A_Loopfilefullpath,,Filedir,,FilenameNoExt,
      RegExMatch(FileDir,"^.*\\(?=[^\\]+\\?$)",Rootpath)
      StringReplace, Foldername, Filedir, %Rootpath%,,   ; now Foldername is the folder name only


Replaced with:
Code:
Splitpath, A_Loopfilefullpath,,Filedir,,FilenameNoExt,
      StringSplit, DirArray, FileDir, \,    ; splits path up into array
      Lastelement = %DirArray0%
      Foldername := DirArray%Lastelement%


First time for me using the Array method of Stringsplit.
Thank you for the nudge. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 25th, 2009, 5:30 am 
Just in case someone follows along on a search someday..
Code:
Splitpath, A_Loopfilefullpath,,Filedir,,FilenameNoExt,
      StringSplit, DirArray, FileDir, \,    ; splits path up into array
      Lastelement = %DirArray0%   ; DirArray now holds the number of sections that were seperated by the \
      Foldername := DirArray%Lastelement%  ; So DirArray(n) holds the 'last' foldername.


..every time I think theres something that AHK 'wont' do.. I stand corrected..


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 25th, 2009, 10:33 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
I'm very happy that you got it going. I used basically the exact same code the other day.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google [Bot], joetazz, Leef_me, Mickers, tidbit, tomoe_uehara, Yahoo [Bot] and 60 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group