This Raku program works as I expect:
sub MAIN($name) { say "Got $name" }
I can pass a single name on the command line:
$ raku m1.raku foo
Got foo
The obvious extension, however,
sub MAIN(@names) { say "Got $_" for @names }
doesn't work:
$ raku mm.raku foo
Usage:
mm.raku <names>
$ raku mm.raku foo bar
Usage:
mm.raku <names>
What am I doing wrong?
Explanation: the expression s/^/1_/ says: "replace the beginning of the filename (that means this symbol -> ^ )' with 1_ ". obviously take it with care; it will remane ALL the files in the current directory that are 'visible' (filename not starting with a '.') You can use pyRenamer.
Run Ranger and navigate to the directory that has the files you wish to rename. I would recommend putting all the .gifs in one directory. Make sure there are no other files except the ones you want to rename.
$ anchors the match to the end of the filename. So the dot, the final digits, and the suffix .gif are matched, and all replaced with just .gif. Show activity on this post.
It's possible to write a shorter rename command that ought to work. I've chosen this approach--among many possible approaches--because the command expresses precisely the naming scheme that you wish to operate on. This is to say that the solution resembles the problem.
What @cjm said.
However, you can go a little further than that, checking whether the names you specified, are actually files. And produce an error message if they are not. The trick is to use multi-dispatch:
subset File of Str where *.IO.f;
multi sub MAIN(*@files where @files.all ~~ File) {
say "These are all files: @files.join(",")";
}
multi sub MAIN(*@files) {
say "These are *NOT* files: @files.grep(* !~~ File).join(",")";
}
The first candidate will be run if all the names specified on the command line are in fact files. The second candidate will be run if the first didn't fire, implying that not all names specified are in fact files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With