Klexen Posted May 11, 2009 Posted May 11, 2009 First let me explain what this is supposed to do...This is supposed to get a list of all folders inside the "Images" folder that start with "12_" Which it does. Then it's supposed to zip up each individual folder that is inside the folder that starts with "12_" which it does.However, I have two problems... 1. If one of the 12_ folders is empty the program will generate a msgbox saying the name of the folder it came across that was empty, and then stop. Would it be possible to exclude folders that start with 12_ but are empty? If so how? If not, how could I make it skip the empty 12_ABCDEF folder and continue to the next one that might not be empty?2. While everything zips the way I want it to... I don't like the fact that the archive is structured like ... 12_ABCDEF/SUBDIRECTORY1/FILESANDFOLDERS I want the archive to only be SUBDIRECTORY1/FILESANDFOLDERS Does that make sense?Thank you!expandcollapse popup#Include <File.au3> #Include <Array.au3> #include <7Zip.au3> ;Get list of folders that contain 12_ and add to array $FileList=_FileListToArray("C:\Imaging\Images\","12_*") If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf ;Delete the count of how many are in array _ArrayDelete($FileList,0) ;Get highest number of row in array $MaxIndex = _ArrayMaxIndex($FileList) ;Get list of folders inside the $FileList array $i = 0 Do $SubList = _FileListToArray("C:\Imaging\Images\"&$FileList[$i]) If @error Then MsgBox(0,"",$FileList[$i] & " " & "is empty") ;Delete the count of how many are in array _ArrayDelete($SubList,0) ;Get highest number of row in array $MaxSubIndex = _ArrayMaxIndex($SubList) ;Zip up all the folders that are in the FileList subdirectories. $b = 0 Do $ArcFile = "\\UAC20\Home\jason\My Documents\programs\"&$FileList[$i]&"\"&$SubList[$b]&".zip" If @error Then Exit $FileName = "C:\Imaging\Images\"&$SubList[$b] If @error Then Exit $retResult = _7ZipAdd(0, $ArcFile, $FileName) $b = $b + 1 Until $b = $MaxSubIndex+1 $i = $i + 1 Until $i = $MaxIndex+1
Authenticity Posted May 11, 2009 Posted May 11, 2009 You can use DirGetSize() to see if the directory is empty of files before passing it's path name to _7ZipAdd() function. Organizing the directory structure to your likes require a recursive function to list all of the directory sub-folders/files and moving them to the top level directory, deleting the reminder empty folders and then passing it to the _7ZipAdd() function. Search the Example Scripts forum for the recursive file listing function, there are quite a lot of them.
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