aa2zz6 Posted March 2, 2018 Share Posted March 2, 2018 I am trying to rename PDF's inside our 2015 Archive folder but I'm not sure how to access each sub folder. #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <File.au3> $FileList = _FileListToArray("C:\Users\jnmiller\Desktop\2015 Archive") If @error = 1 Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf For $i = 1 To $FileList[0] MsgBox(0, $i, $FileList[$i]) ; Find pdf's in folders $sFileOld = "C:\Users\jnmiller\Desktop\2015 Archive\" & "\*.pdf*" ; Get folder name $renamePDF = StringSplit(@ScriptDir,"\",0) ; Change pdf name to match folder name FileMove($sFileOld, $renamePDF[$renamePDF[0]] & ".pdf") ; Create variable for new dest Local $newDest = "C:\Users\jnmiller\Desktop\Store PDF Files" ; Move pdf's to NEO Service Line Scans FileMove($renamePDF[$renamePDF[0]] & ".pdf",$newDest,0) Next Link to comment Share on other sites More sharing options...
Andreik Posted March 2, 2018 Share Posted March 2, 2018 You can use _FileListToArrayRec(). When the words fail... music speaks. Link to comment Share on other sites More sharing options...
aa2zz6 Posted March 2, 2018 Author Share Posted March 2, 2018 (edited) 6 hours ago, Andreik said: You can use _FileListToArrayRec(). Hi, I am having trouble understanding this function. I am using the _FileListToArrayRec function and it's listing the pdf's in an _ArrayDisplay but it's not able to rewrite the pdf's to another file like the _FileListToArray function before. expandcollapse popup#include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <File.au3> #include <Array.au3> Global $aArray = _FileListToArrayRec("C:\Users\jnmiller\Desktop\test123", "*.pdf", _ $FLTAR_FILES+$FLTAR_NOSYSTEM+$FLTAR_NOHIDDEN, _ $FLTAR_RECUR, $FLTAR_FASTSORT, $FLTAR_FULLPATH) ; Display Results ; _ArrayDisplay($aArray, " Results") ;$FileList = _FileListToArray("C:\Users\jnmiller\Desktop\test123") If @error = 1 Then ;MsgBox(0, "", "No Files\Folders Found.") Exit EndIf For $i = 1 To $aArray[0] ;MsgBox(0, $i, $FileList[$i]) ; Find pdf's in folders ;$sFileOld = "C:\Users\jnmiller\Desktop\test123\" & "\*.pdf*" ; Get folder name $renamePDF = StringSplit(@ScriptDir,"\",0) ; Change pdf name to match folder name FileMove($aArray, $renamePDF[$renamePDF[0]] & ".pdf") ; Create variable for new dest Local $newDest = "C:\Users\jnmiller\Desktop\Store PDF Files" ; Move pdf's to NEO Service Line Scans FileMove($renamePDF[$renamePDF[0]] & ".pdf",$newDest,0) Next Edited March 2, 2018 by aa2zz6 Spelling Correction Link to comment Share on other sites More sharing options...
Subz Posted March 2, 2018 Share Posted March 2, 2018 So do you only have one pdf in each of the folders? Link to comment Share on other sites More sharing options...
aa2zz6 Posted March 2, 2018 Author Share Posted March 2, 2018 6 minutes ago, Subz said: So do you only have one pdf in each of the folders? Yes, that's correct. Link to comment Share on other sites More sharing options...
Subz Posted March 2, 2018 Share Posted March 2, 2018 So you want something like this? #include <Array.au3> #include <File.au3> #include <FileConstants.au3> Global $aFileList = _FileListToArrayRec(@DesktopDir & "\test123", "*.pdf", _ $FLTAR_FILES+$FLTAR_NOSYSTEM+$FLTAR_NOHIDDEN, _ $FLTAR_RECUR, $FLTAR_FASTSORT, $FLTAR_FULLPATH) If @error = 1 Then Exit ; Display Results ;~ _ArrayDisplay($aFileList, " Results") Global $aRenamePDF For $i = 1 To $aFileList[0] ; Get folder name $aRenamePDF = StringSplit($aFileList[$i],"\") ; Change pdf name to match folder name FileMove($aFileList[$i], @DesktopDir & "\Store PDF Files\" & $aRenamePDF[$aRenamePDF[0] - 1] & ".pdf", 8) Next aa2zz6 1 Link to comment Share on other sites More sharing options...
aa2zz6 Posted March 2, 2018 Author Share Posted March 2, 2018 (edited) Incredible I wouldn't of figured that out. Edited March 2, 2018 by aa2zz6 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