You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rename a section of a filename, i. e. example.1.{txt,conf,db} or 12345.1.{wav,ogg,mp3} and change the 1 to a 2 in the filename while preserving the rest of it.
zmv -n '(*.)(<->)(.[^.]#)''$1$(($2+1))$3'# would rename x.0001.y to x.2.y.
zmv -n '(*.0#)(<->)(.[^.]#)''$1$(($2+1))$3'
Rename files to lower case
$ zmv '*''${(L)f}'
serially all files (foo.foo > 1.foo, fnord.foo > 2.foo, ..)
adding leading zeros to a filename (1.jpg -> 001.jpg, ..)
$ zmv '(<1->).jpg''${(l:3::0:)1}.jpg'
See above, but now only files with a filename >= 30 chars
$ c=1 zmv "${(l:30-4::?:)}*.foo"'$((c++)).foo'
Replace spaces in filenames with a underline
$ zmv '* *''$f:gs/ /_'
Change the suffix from *.sh to *.pl
$ zmv -W '*.sh''*.pl'
Add a "".txt" extension to all the files within ${HOME}
# ``-.'' is to only rename regular files or symlinks to regular files,# ``D'' is to also rename hidden files (dotfiles))
$ zmv -Q '/home/**/*(D-.)''$f.txt'# Or to only rename files that don't have an extension:
$ zmv -Q '/home/**/^?*.*(D-.)''$f.txt'
Removing single quote from filenames (recursively)
$ zmv -Q "(**/)(*'*)(D)""\$1\${2//'/}"
When a new file arrives (named file.txt) rename all files in order to get (e. g. file119.txt becomes file120.txt, file118.txt becomes file119.txt and so on ending with file.txt becoming file1.txt