jslegers Posted September 6, 2010 Posted September 6, 2010 (edited) Hello,I have seen this topic :http://www.autoitscript.com/forum/index.php?showtopic=110281&st=0&p=775935&hl=nfo&fromsearch=1&#entry775935Is it possible to run this script on files in sub directories ?Example structure :[Dir] Movie1Movie1.mkv[Dir] Movie2Movie2.mkv[Dir] Movie3Movie3.mkvResult :[Dir] Movie1Movie1.mkvMovie1.nfo[Dir] Movie2Movie2.mkvMovie2.nfo[Dir] Movie3Movie3.mkvMovie3.nfoThe .nfo files need to be filled with an url of IMDB I will copy and paste that.And if there is already an .nfo file it needs to skip the directory before it clears the old .nfo file.John Edited September 6, 2010 by jslegers
Triblade Posted September 6, 2010 Posted September 6, 2010 (edited) Is it possible to run this script on files in sub directories ?Yes, it's possible.But don't expect 'us' to script it for you. This is a general help forum, post a sample script you made and comments where you are stranded. Then we could try to fix your non-working code. And please don't post an exact copy of the code from the link. Edit:Ow, and please read this: Example for reproduction Edited September 6, 2010 by Triblade My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger)
Varian Posted September 6, 2010 Posted September 6, 2010 (edited) This should get you there in rough form; I did not create the "_FileListToArray_Recursive" function, found it on the Forumexpandcollapse popup#include <Array.au3> Local $MediaFolder = 'Path To Root of your Media Folder' Local $Array = _FileListToArray_Recursive($MediaFolder, '*', 1, 2, True) If Not IsArray($Array) Then Exit For $i = $Array[0] To 1 Step -1 If Not StringRegExp($Array[$i], '(?i)avi$|(?i)mpg$|(?i)mpe$|(?i)mpeg$|(?i)mkv$|(?i)wmv$', 0) Then ;Add or remove extensionss to suit your needs _ArrayDelete($Array, $i) Else If FileExists(StringTrimRight($Array[$i], 4) & '.nfo') Then _ArrayDelete($Array, $i) ;If file passes your media filter, then check to see if NFO exists..if it does, remove it from the array EndIf Next $Array[0] = UBound($Array) - 1 _ArrayDisplayEx($Array, 'Media Files without Corresponding NFO') For $i = 1 To $Array[0] If Not FileExists(StringTrimRight($Array[$i], 4)) & '.nfo' Then Local $File = FileOpen(StringTrimRight($Array[$i], 4) & '.nfo', 2) FileClose($File) EndIf Next ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Functions Start;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;=============================================================================== ; $iRetItemType: 0 = Files and folders, 1 = Files only, 2 = Folders only ; $iRetPathType: 0 = Filename only, 1 = Path relative to $sPath, 2 = Full path/filename Func _FileListToArray_Recursive($sPath, $sFilter = "*", $iRetItemType = 0, $iRetPathType = 0, $bRecursive = False) Local $sRet = "", $sRetPath = "" $sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") If Not FileExists($sPath) Then Return SetError(1, 1, "") If StringRegExp($sFilter, "[\\/ :> <\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "") $sPath &= "\|" $sOrigPathLen = StringLen($sPath) - 1 While $sPath $sCurrPathLen = StringInStr($sPath, "|") - 1 $sCurrPath = StringLeft($sPath, $sCurrPathLen) $Search = FileFindFirstFile($sCurrPath & $sFilter) If @error Then $sPath = StringTrimLeft($sPath, $sCurrPathLen + 1) ContinueLoop EndIf Switch $iRetPathType Case 1 ; relative path $sRetPath = StringTrimLeft($sCurrPath, $sOrigPathLen) Case 2 ; full path $sRetPath = $sCurrPath EndSwitch While 1 $File = FileFindNextFile($Search) If @error Then ExitLoop If ($iRetItemType + @extended = 2) Then ContinueLoop $sRet &= $sRetPath & $File & "|" WEnd FileClose($Search) If $bRecursive Then $hSearch = FileFindFirstFile($sCurrPath & "*") While 1 $File = FileFindNextFile($hSearch) If @error Then ExitLoop If @extended Then $sPath &= $sCurrPath & $File & "\|" WEnd FileClose($hSearch) EndIf $sPath = StringTrimLeft($sPath, $sCurrPathLen + 1) WEnd If Not $sRet Then Return SetError(4, 4, "") Return StringSplit(StringTrimRight($sRet, 1), "|") EndFunc ;==>_FileListToArray_Recursive Edited September 6, 2010 by Varian
jslegers Posted September 6, 2010 Author Posted September 6, 2010 This should get you there in rough form; I did not create the "_FileListToArray_Recursive" function, found it on the Forumexpandcollapse popup#include <Array.au3> Local $MediaFolder = 'Path To Root of your Media Folder' Local $Array = _FileListToArray_Recursive($MediaFolder, '*', 1, 2, True) If Not IsArray($Array) Then Exit For $i = $Array[0] To 1 Step -1 If Not StringRegExp($Array[$i], '(?i)avi$|(?i)mpg$|(?i)mpe$|(?i)mpeg$|(?i)mkv$|(?i)wmv$', 0) Then ;Add or remove extensionss to suit your needs _ArrayDelete($Array, $i) Else If FileExists(StringTrimRight($Array[$i], 4) & '.nfo') Then _ArrayDelete($Array, $i) ;If file passes your media filter, then check to see if NFO exists..if it does, remove it from the array EndIf Next $Array[0] = UBound($Array) - 1 _ArrayDisplayEx($Array, 'Media Files without Corresponding NFO') For $i = 1 To $Array[0] If Not FileExists(StringTrimRight($Array[$i], 4)) & '.nfo' Then Local $File = FileOpen(StringTrimRight($Array[$i], 3) & '.nfo', 2) FileClose($File) EndIf Next ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Functions Start;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;=============================================================================== ; $iRetItemType: 0 = Files and folders, 1 = Files only, 2 = Folders only ; $iRetPathType: 0 = Filename only, 1 = Path relative to $sPath, 2 = Full path/filename Func _FileListToArray_Recursive($sPath, $sFilter = "*", $iRetItemType = 0, $iRetPathType = 0, $bRecursive = False) Local $sRet = "", $sRetPath = "" $sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") If Not FileExists($sPath) Then Return SetError(1, 1, "") If StringRegExp($sFilter, "[\\/ :> <\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "") $sPath &= "\|" $sOrigPathLen = StringLen($sPath) - 1 While $sPath $sCurrPathLen = StringInStr($sPath, "|") - 1 $sCurrPath = StringLeft($sPath, $sCurrPathLen) $Search = FileFindFirstFile($sCurrPath & $sFilter) If @error Then $sPath = StringTrimLeft($sPath, $sCurrPathLen + 1) ContinueLoop EndIf Switch $iRetPathType Case 1 ; relative path $sRetPath = StringTrimLeft($sCurrPath, $sOrigPathLen) Case 2 ; full path $sRetPath = $sCurrPath EndSwitch While 1 $File = FileFindNextFile($Search) If @error Then ExitLoop If ($iRetItemType + @extended = 2) Then ContinueLoop $sRet &= $sRetPath & $File & "|" WEnd FileClose($Search) If $bRecursive Then $hSearch = FileFindFirstFile($sCurrPath & "*") While 1 $File = FileFindNextFile($hSearch) If @error Then ExitLoop If @extended Then $sPath &= $sCurrPath & $File & "\|" WEnd FileClose($hSearch) EndIf $sPath = StringTrimLeft($sPath, $sCurrPathLen + 1) WEnd If Not $sRet Then Return SetError(4, 4, "") Return StringSplit(StringTrimRight($sRet, 1), "|") EndFunc ;==>_FileListToArray_Recursive Thanks for the replies. I will try it.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now