--- In [email protected], Alan Martin <[EMAIL PROTECTED]> wrote:
Hi Alan, What a rain! It's the rainy season here. > You wrote: > > do(if(not file.listfiles(arg(1),1),"file.deletenorecycle(arg(1))")) > > and in snowman's thread: > > > do(if(not file.listfiles(?"C:\path",1),?'file.deletenorecycle(?"C:\path")')) > > Ah yes, I was looking at the if( , ) function > but I didn't think of wrapping it in a do() > > Your solution doesn't work recursively when tested here. > > I used a test tree where the parent folder has a file > and only some of the subfolders contain a file: > > c:\test\ contains: file.txt > > c:\test\one\ contains: file.txt > c:\test\one\onesub\ contains: [no files] > > c:\test\two\ contains: [no files] > c:\test\two\twosub\ contains: [no files] > > c:\test\three\ contains: [no files] > c:\test\three\threesub\ contains: file.txt > > My script works, deleting all empty folders and no files. > Maybe it can only be done with a subroutine. Sure. The two are supposed to achieve different jobs. I guessed that he simply wanted to delete a folder with all its subfolders when it's empty, by which he meant no files under the folder. > ;;----------- DelEmptyFolders.powerpro ------ > > ;; arg(1) is the parent folder > file.allfiles(arg(1),"[EMAIL PROTECTED](_file_)",5) > quit > > @sub > ;; arg(1) is one of the subfolders > if(not file.listfiles(arg(1),1)) > file.delete(arg(1)) > quit > > ;;--------------------------------------- You may do this: ;all in 1 line below file.allfiles(?"C:\path", ?'do(if(not file.listfiles(_file_,1),"file.delete(_file_)"))',5) ;all in 1 line above If it's in a script file, you may use: ;all in 1 line below @sub quit(file.allfiles(arg(1), ?'do(if(not file.listfiles(_file_,1),"file.delete(_file_)"))',5)) ;all in 1 line above Although I don't recommend this form of syntax to beginners, it might be a challenge to the experienced users, and might deepen to some extent understanding of PP's syntax. Sean ------------------------ Yahoo! Groups Sponsor --------------------~--> Great things are happening at Yahoo! Groups. See the new email design. http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/JV_rlB/TM --------------------------------------------------------------------~-> Attention: PowerPro's Web site has moved: http://www.ppro.org Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/power-pro/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
