`File.file?` and `File.directory?` are mutually exclusive.  I suggest changing this to use `partition`:

```ruby
files, directories = expanded_filepaths.partition { |fp| File.file?(fp) }

# do whatever with files
# do whatever with dirs
```