thameera / vimv Goto Github PK
View Code? Open in Web Editor NEWBatch-rename files using Vim
License: MIT License
Batch-rename files using Vim
License: MIT License
8ee5d21 introduces the set -eu
command that instructs the script to terminate on first exit with a non-zero status.
But this line poses a problem:
Because if you look at ((
help page, it says:
Exit Status:
Returns 1 if EXPRESSION evaluates to 0; returns 0 otherwise.
Since ((count++))
increases the variable returning its previous value, and count
begins at 0, first ((count++))
returns 1 like the help page says, because the expression evaluates to 0. This causes the program to terminate prematurely on first rename.
This ZIP archive contains the example from the README (all the files are just empty files created by touch
). To reproduce the issue, try to follow the example by removing Rick and Morty
using visual block. After proceeding you will see that only the first file (S01E01 Pilot.mp4
) has been renamed.
The solution to this problem is very simple, just change the order of ++
so that the expression doesn't evaluate to 0:
((++count))
And this is exactly what my referenced pull request does.
If an input file contains a newline, there's no way to distinguish between
that newline and the newline the terminates the file name in the editor buffer.
While workarounds exist (for example, separate the file names with null bytes),
I'm not sure how that would affect the usability of the script without significant
editor-specific configuration.
I would recommend simply aborting if any source name contains a newline, letting
the caller deal with the issue manually.
This could be done by adding a number to each line and sorting by that number after the editor finishes.
it always default to vim
I tried micro, nano
It won't work.
Hi,
I really like vimv, but had to hack it to work with py3. It works for me but I think might like py3 compatibility as well.
Cheers!
I edited my personal copy to do this, using a while loop and breaking whenever the src and dest are the same or the dest already exists. This seems to me to be the expected behaviour.
I have a copy of it here: https://gist.github.com/elundmark/bf1e3fc925aa8d8472ea449e4f6766f2
Example:
file1
file2
press 'dd' on line 2 then ':wq'
Can be done differently.
as per man pages:
"The template may be any filename with at least six โXsโ appended to it"
Is there a way to rename files like that?
Holiday-01.jpeg
Holiday-02.jpeg
...
I often use vimv to number files from abc, xyz to 01.abc 02.xyz etc. using macros
However, by default the vimv buffer displays all files in natural/alphanumeric sort.
Any support to sort the files according to ctime or mtime would be great :)
Steps to reproduce:
for i in $(seq 0 9); do touch "file ($i).txt"; done
vimv *
file (0).txt
file (1).txt
file (2).txt
file (3).txt
file (4).txt
file (5).txt
file (6).txt
file (7).txt
file (8).txt
file (9).txt
file (1).txt
file (2).txt
file (3).txt
file (4).txt
file (5).txt
file (6).txt
file (7).txt
file (8).txt
file (9).txt
file (10).txt
file (10).txt
๐ขI think using releases would make it simpler for people to package this for Linux distributions.
Hi. Subject. I'm just trying to decide which tool to use. Thanks.
Allow to specify an option, to optionally (maybe by default) confirm deletions and/or renames:
old_file โ new_file
The outputs can be colored as well.
I'd prefer multi-line output, git style.
If the list is long, or always, use less to not flood the screen.
vimv assumes /tmp
as the temporary directory. It isn't the case on some systems, like Android's Termux (actually, this is probably Android's fault and not Termux', come to think of it).
$TMPDIR
is a commonly used variable to indicate where the temporary directory is in this system, or may be what directory the user wants you to use (Wikipedia, Ubuntu's Wiki).
On the other hand, you can't just use TMPDIR without a default, because some other systems don't set it, like Ubuntu on WSL. I that case I suggest vimv should go on using /tmp, which is the most common and actually what Ubuntu on WSL uses.
Here is a PR: #12
PD: By the way, I love vimv and use it every day, thanks!
Input:
o1_foo.png
o1_bar.png
o1_baz.png
o2_baz.png
ls | wc -l # 4
vimv transform:
foo.png
bar.png
baz.png
bar.png
result:
foo.png
bar.png
baz.png
Either fail, or present the conflicted files (with possibly the original name as well, bonus points for checksum) only the second time.
I'm not sure what the problem is, but whenever I open vimv, it opens with Nano instead of Vim. I can use Nano no problem, but it's just a bit of an annoyance when Vim has so much more functionality, and when this is supposed to open Vim.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.