dotfiles/bin/moov
2020-07-18 15:11:20 +02:00

22 lines
406 B
Fish
Executable File

#!/usr/bin/env fish
# syntax: moov files... regex target
set regex $argv[-2]
set target $argv[-1]
set files $argv[1..-3]
for file in $files
set matches (string match -ar "$regex" "$file")
set target_path "$target"
set counter 0
for match in $matches
set target_path (string replace -a '$'"$counter" "$match" "$target_path")
set counter (math $counter + 1)
end
mv "$file" "$target_path"
end