You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
406 B
Plaintext
22 lines
406 B
Plaintext
4 years ago
|
#!/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
|
||
|
|