Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

if any [not suffixes find suffixes find/last file "."] [

 [1/5] from: princepawn:lycos at: 7-Sep-2000 8:22


I am trying to understand the following script and dont quite understand the mechanics of this line right here: if any [not suffixes find suffixes find/last file "."] [ I understand not suffixes completely I dont understand find suffixes find/last file "." at all suffixes is a block of suffixes, but I dont understand how all this works together, particularly. the "." part. REBOL [ Title: "Delete Files by Suffix" Date: 7-July-2000 File: %delete-suffix.r Author: "Reburu" Purpose: { Delete files based on their suffixes. Can also delete deeply through all subdirectories. } Note: {Press ESCAPE to break out at the prompt.} Category: [file util 3] ] delete-suffix: func [ "Delete files deeply by suffix." dir-name "Starting directory" suffixes "Block of suffixes or none" /deep "Delete into subdirectories" /sure "Do not verify the deletion" ][ if dir? dir-name [ dir-name: dirize dir-name ;print ["Inspecting:" dir-name] foreach file read dir-name [ either dir? dir-name/:file [ if deep [ either sure [ delete-suffix/deep/sure dir-name/:file suffixes ][ delete-suffix/deep dir-name/:file suffixes ] ] ][ if any [not suffixes find suffixes find/last file "."] [ if any [ sure confirm ["Delete" dir-name/:file "? "] ][ print ["Deleting:" dir-name/:file] delete dir-name/:file ] ] ] ] ] ] ;Examples: ;delete-suffix %. none ; delete all files ;delete-suffix/deep %. [%.jpg %.gif %.bmp] ; delete image files ;delete-suffix/deep %msvc [%.sbr %.obj %.pdb %.ilk %.pch %.bsc %.idb] delete-suffix/deep/sure %. [%.err] ; delete all error files for s

 [2/5] from: johnkenyon::uk::ibm::com at: 7-Sep-2000 8:57


Hi again, Look at
>> help any
Maybe more readable with extra brackets to emphasize the execution order - if any [not suffixes find suffixes find/last file "."] [ .... is the same as .... if (not suffixes) or (find suffixes (find/last file "."))] [ Any better? cheers, john I am trying to understand the following script and dont quite understand the mechanics of this line right here: if any [not suffixes find suffixes find/last file "."] [ I understand not suffixes completely I dont understand find suffixes find/last file "." at all suffixes is a block of suffixes, but I dont understand how all this works together, particularly. the "." part.

 [3/5] from: princepawn:lycos at: 7-Sep-2000 9:23


I think it makes sense now... but: how could I use a wildcard such as the find/any wildcard to find the file, e.g.: find/any file-list "*.r" --- On Thu, 7 Sep 2000 8:57:15 - johnkenyon wrote:

 [4/5] from: johnkenyon:ibm at: 7-Sep-2000 10:00


Hi, Do you mean ... foreach file-name file-list [ if find/any file-name "*.r" [ print join "found " file-name ] ] ? cheers, john I think it makes sense now... but: how could I use a wildcard such as the find/any wildcard to find the file, e.g.: find/any file-list "*.r"

 [5/5] from: bhandley:zip:au at: 8-Sep-2000 10:42


Just a note. There is an enhancement request for find so that it return values like John's code suggests but without requiring the loop. Brett. ----- Original Message ----- From: <[johnkenyon--uk--ibm--com]> To: <[list--rebol--com]> Sent: Friday, September 08, 2000 3:00 AM Subject: [REBOL] if any [not suffixes find suffixes find/last file "." ] Re:(3)