AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need ouput foldername to be same as input foldername..

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Dave72



Joined: 27 Jan 2007
Posts: 30
Location: Canada

PostPosted: Sun Aug 23, 2009 7:12 pm    Post subject: Need ouput foldername to be same as input foldername.. Reply with quote

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..)
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Mon Aug 24, 2009 10:12 am    Post subject: Reply with quote

SplitPath and SplitString Aren't covering your needs?
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
Dave72



Joined: 27 Jan 2007
Posts: 30
Location: Canada

PostPosted: Tue Aug 25, 2009 12:12 am    Post subject: Reply with quote

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. Smile
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Aug 25, 2009 4:30 am    Post subject: Reply with quote

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..
Back to top
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Tue Aug 25, 2009 9:33 am    Post subject: Reply with quote

I'm very happy that you got it going. I used basically the exact same code the other day.
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group