dufran3 Posted September 7, 2010 Share Posted September 7, 2010 Ok, here is what I'm trying to do, and I will post what I have so far. I have a directory...C:\Movies. I want to enumerate the number of directories inside of that directory, and create a count. I then want to somehow put the names of all of those directories into an array. And be able to change the directory names base on content. Basically, I have a movie collection, and want to search IMDB for the production year, using the directory name, say for example C:\Movies\The Dark Knight, and then rename the directory to say, The Dark Knight (2009). Not sure if this is even possible, but this is what I have so far. expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Movie Finder", 300, 200) GLOBAL $inputctrl = GUICtrlCreateInput('Input Movie Directory to Scan',1,1) $OkButton = GUICtrlCreateButton('GO',20,180) GUICTRLSetonEvent($OkButton, '_GO') $ExitButton = GUICtrlCreateButton('Exit',50,180) GUICtrlSetOnEvent($ExitButton, '_Exit') GUISetOnEvent($GUI_EVENT_CLOSE, 'exitier', $mainwindow) GUISetState(@SW_SHOW) While 1 Sleep(1000) ; Idle around WEnd Func _GO() GLOBAL $Directory = GUICtrlRead($inputctrl) _Scan($Directory) EndFunc Func _Scan($directory) $array1 = DirGetSize($directory,1) $arraysize = $array1[2] Dim $aMovies[$arraysize] Exit EndFunc Func _Exit() Exit EndFunc Func Exitier() Exit EndFunc ;==>Exitier Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 7, 2010 Moderators Share Posted September 7, 2010 dufran3,I want to enumerate the number of directories inside of that directory, and create a countLook at _FileListToArray in the Help file. If you set $iFlag to 2, you only list the folders. be able to change the directory names base on contentLook at StringInStr to find which folder names contain the required text and then DirMove to change the name.All clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
dufran3 Posted September 7, 2010 Author Share Posted September 7, 2010 (edited) Those functions work. Was trying to get the _FileListtoArray function to create a 2 dimension array, so that I can store the year for each movie in $array[$][0], still trying to figure that one out. Also, do you have any idea of a good way to get the movie year into the script? Seems like there would be an easier way than opening a browser, navigating to IMDB and trying to search the text for a year....thanks for your help thus far! This is what I have now: trying to figure out the best way to populate the $Year and $Type. I figure I will scan the subfolder, and if a .mkv is found, set to [blu-ray], if Video_TS is found, set to [DVD]. But still need to work on the logistics of that. expandcollapse popup#include <GUIConstantsEx.au3> #include <File.au3> #include <Array.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Movie Finder", 300, 200) GLOBAL $inputctrl = GUICtrlCreateInput('Input Movie Directory to Scan',1,1) $OkButton = GUICtrlCreateButton('GO',20,180) GUICTRLSetonEvent($OkButton, '_GO') $ExitButton = GUICtrlCreateButton('Exit',50,180) GUICtrlSetOnEvent($ExitButton, 'Exitier') GUISetOnEvent($GUI_EVENT_CLOSE, 'exitier', $mainwindow) GUISetState(@SW_SHOW) While 1 Sleep(1000) ; Idle around WEnd Func _GO() GLOBAL $Directory = GUICtrlRead($inputctrl) _Scan($Directory) EndFunc Func _Scan($directory) $aMovies = _FileListToArray($directory,'*',2) _ArrayDisplay($aMovies,"$FileList") For $i = 1 to $aMovies[0] $Year = '2009' $Type = 'Blu-ray' MsgBox(0,'','Move From: ' & @CRLF & $Directory & '\' & $aMovies[$i] & @CRLF &' To: ' & @CRLF & $Directory & '\' & $aMovies[$i] & ' [' & $Year & ']' & ' ' & '[' & $Type & ']') ;DirMove($Directory & '\' & $aMovies[$i], $Directory & '\' $aMovies[$i] & '[' & $Year & ']' & ' ' & '[' & $Type & ']',1) Next Exit EndFunc Func Exitier() Exit EndFunc ;==>Exitier Edited September 7, 2010 by dufran3 Link to comment Share on other sites More sharing options...
Varian Posted September 8, 2010 Share Posted September 8, 2010 (edited) Glad to see your NFO problem is solved. One of the problems loading the movie info from IMDB is that there is often more than resultant one movie title so IMDB shows a list of titles. I think you would be fetter served by populating the corresponding NFO with the correct link and read your results from that NFO. Here is a rough script that can give you some insight (maybe) on doing an IMDB search. Once again, this is rough so if you want find a more efficient way of doing this, you should. REQUIRES Firefox and FF.au3(found on the forum)#include <FF.au3> Local $File, $Movie, $Phrases $Phrases = '(?i)DVDRip|(?i)DVDscr|(?i)R5|(?i)english|(?i)720p|(?i)1080p|(?i)1080i|(?i)BluRay|(?i)PROPER|(?i)x264|(?i)HDTV|(?i)HDDVD|(?i)UNRATED|(?i)REPACK|(?i)LIMITED|(?i)DTS|(?i)xvid|(?i)divx|(?i)mkv|(?i)avi|(?i)mpg|(?i)mp4|\[.*\]|\(.*\)|\{.*\}' ;Next If...Endif opens File Open Dialouge if not compiled and no Parameters are sent If $CmdLine[0] = 0 Then $File = FileOpenDialog("Select an AVI file", @ScriptDir, "AVI Files (*.avi)", 1) If @error Then Exit Else $File = $CmdLine[1] EndIf $Movie = StringRegExpReplace($File, '^.+\\|\.avi$', '') ;returns the AVI file name minus the path and extension $Movie = StringRegExpReplace($Movie, $Phrases, '') ;Strips common phrases/brackets, parentheses, and braces (and text between) $Movie = StringRegExpReplace($Movie, ' *$', '') ;removes trailing spaces $Movie = StringRegExpReplace($Movie, ' ', '+') ;replaces spaces between words with "+" for correct IMDB search MsgBox(32, 'Result', 'Ready to search IMDB for: ' & $Movie) ;shows the phrase to be searched in IMDB If Not $Movie Then Exit ;if $Movie is blank, exit _FFConnect() ;open Firefox session and connect Do Sleep(10) Until _FFIsConnected() ;Idle around until Firefox connection established _FFTabAdd('http://imdb.com/find?' & $Movie) ;Search IMDB for your phrase _FFLoadWait() ;Wait until IMDB search page has loaded MsgBox(32, 'Finished', 'Page finished loading...check results') ;exit message Exit Edited September 8, 2010 by Varian Link to comment Share on other sites More sharing options...
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