Main problem: you maybe don't do this kind of operation frequently enough to remember how it's called or how you aliased it.
Main problem: you maybe don't do this kind of operation frequently enough to remember how it's called or how you aliased it.
https://github.com/nmaggioni/wat
The tag system is especially useful to me when I know the general concept I'm after but don't remember the exact wording of the command.
If your problem can be solved by just regexps, there's a "rename" tool installed by Perl I've used for decades. E.g.
rename -n 's/JPEG$/jpg/' *JPEG
Will apply the substitution for JPEG at end of the filename to just jpg. The -n will run without renaming so you can see what it intends to do.What you have installed, and what Debian and its derivates ship is this: https://metacpan.org/pod/distribution/File-Rename/rename.PL
Most(?) other distros ship the one from util-linux: http://man7.org/linux/man-pages/man1/rename.1.html
In my app, you can rename using your favorite code editor, so you have access to all your keyboard shortcuts.
https://github.com/whyboris/Simplest-File-Renamer - MIT open source
I think folks should be aware of 'vimv' which opens your pwd in an editor and you just edit your filenames in 'vi' ... and all of the renaming happens upon saving and quitting.
Not sure if this is the official/canonical distribution, but for what it's worth:
$ ls / find # tweak until I have a list of things to rename
$ for file in $(ls / find...); do echo "mv $file $(echo $file | sed ... )"; done # this prints mv commands for renaming, I can inspect them as needed
$ for file in $(); do...; done | sh # execute the renaming
It is inspectable, easy to cancel (just don't pipe to shell), incremental... just needs wrangling with bash etc. which is a bit of a pain.It works for a bunch of other all-or-nothing commands, which are potentially quite destructive; use a for-loop to generate the commands, tweak until you're happy with it, then pipe to shell.
ls | % {rename-item $_ -newname $('myfile_' + ($_.BaseName -replace '\D') + '.md' )}
No need to remember anything.Nope.
> to remeber
That's the point, you don't need to remember anything, it would come naturally after a day of tinkering with PS/pwsh.
You just write it for your current needs.
This example was just a quick one-liner, it's very simple:
ls | % { # get the file list, cycle for each item
rename-item # obvious usage: rename-item oldname newname
$_ # pretty obvious, the source - place the loop variable here ie file name
-newname # explicit calling for a parameter name, isn't really needed
$( # subroutine start or eval if you prefer, to construct the new file name:
# 'text' + (take property basename from the file and regex it) + 'text'
'myfile_' + ($_.BaseName -replace '\D') + '.md'
) # subroutine end
} # cycle end.
It could be simplified (in this example) to this: ls | % {
$a = 'myfile_' + ($_ -replace '\D') + '.md'
rename-item $_ $a
}
which could be even written as a one-liner if you prefer it right now, just add a semicolon after `$a = ...` ls | % {$a = 'myfile_' + ($_ -replace '\D') + '.md'; rename-item $_ $a } !ls
qaVypImv “escapeA” escapeJi”escapeA”escapejq99@a