  rem -- We have to make a file list. We can't use the
  rem -- wildcards (*.*) with filecopy and have a progress bar. 
  rem -- The progress bar works in percentage 1% to 100%. So
  rem -- if we have 20 files, we increment the progress bar by
  rem -- 5 for every file. If we have 200 files, we increment
  rem -- by 1 for every 2 files, etc.  Gotta get that 100%.

  OPTION SCALE, 96
  OPTION DECIMALSEP, "."
  Title By Mac
  Dialog CREATE, Multiple File Copy,-1,0,240,55
  DIALOG ADD,Text,Status,5,80,,,"Copying Files..."
  Dialog ADD,PROGRESS,ProgBar,25,5,230,24
  DIALOG SHOW

  rem -- This example copies files from Windows
  rem -- to a directory named for today's date.
  rem -- Change %c and %d as needed --

  rem -- Location of files to copy --
  %c = c:\Windows
  DIRECTORY CHANGE, %c

  rem -- Path to new directory (this one uses date as name).
  %d = c:\@datetime(ddmmyy)

  rem -- Check if directory exists... 
  if @not(@file(%d, D))
    DIRECTORY CREATE, %d
  else 
    if @not(@ask(Directory '%d' already exists.@tab()@cr()@cr()Copy files anyway?))
      goto CLOSE
    end 
  end 

  rem -- Create a list --
  LIST CREATE, 1

  rem -- Load filenames into list 1 --
  LIST FILELIST, 1, %c\*.*

  rem -- Get number of files in list --
  %n = @count(1)

  rem -- Check if files are found --
  if @greater(1, %n)
    INFO Directory does not exist or is empty.@tab()
    goto CLOSE
  end 

  rem -- Get our number to increment progress bar by...
  if @greater(%n, 100)
    rem -- If more than 100 files --
    %q = @fdiv(%n, 100)
  else 
    rem -- If 100 files or less --
    %q = @fdiv(100, %n)
  end 
  GOSUB CopyFiles
  INFO Finished!
  goto CLOSE

:CLOSE
  EXIT 

  rem ---- GOSUB ROUTINE ----

:CopyFiles
  rem -- Round off %q to a whole number --
  %q = @format(%q, .0)
  %p = 0
  %x = 0
  REPEAT 
    rem -- Copy next file in list.
    FILE COPY, @item(1, %x), %d
    rem -- Increment variable and progress bar by %q amount --
    if @greater(%n, 100)
      if @equal(@mod(@index(1), %q), 0)
        %p = @succ(%p)
        DIALOG SET, ProgBar, %p
      end 
    else 
      %p = @prod(%q, @index(1))
      DIALOG SET, ProgBar, %p
    end 
    %x = @succ(%x)
  UNTIL @equal(%x, @count(1))
  exit 
