Coder Social home page Coder Social logo

rnr's People

Contributors

ismaelgv avatar lucas-deangelis avatar seanwatson avatar xyb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rnr's Issues

Confirming cli app only

Hello!

Thanks for a great tool. I have an mp3 library I'm trying to wrangle into consistency and rnr has smoothed that path quite nicely. I especially appreciate undo file/dry-run by default.

Anyway, I think it's not possible, but can rnr be incorporated into another rust app via a crate dependency, i.e. is there an api implementation for rnr? Or is the only option to use rnr from within a rust program to call rnr via std process Command?

Thanks!

ascii restriction mode

Issue Description

i am using this tool mainly to fix filesystem issues that i am having after working with different files from different sources, an example being files using UTF-8 character set outside the standard ascii range like Asian, Slavic, extended Latin or German special characters (i.e. 'ąłśćż' ). Those files while working on modern file systems like btrfs without a problem but in some cases, for example when being copied or transferred to file systems not supporting UTF-8 out of the box, it's erroneous or just prevents me from doing so, since the drivers do not know what to do with those.
Here comes the RnR which i use to strip those as far as i am able to, but it takes some wizardry to do properly and i am still not sure if i am not overlooked something. Also, it's extremely lossy at this moment.

Resolution Proposition

there is an library that translates the special characters to ASCII bound ones - https://github.com/anyascii/anyascii
can we get a flag that for example in addition to running regexp, forces the special characters to be conversed to the ascii ones? for example, --restrict

this issue is related mainly to unix/linux platform.

regex to remove white spaces in folder names

Hi, I want to replace multiple continuous whitespaces to 1 in the folder names. However the following regex doesn't work:
rnr -Dr '\s+' ' ' . Any idea?

If I use '\s{2,}' instead of '\s+', it works as expected. It seems the + is not supported?

Logo proposal

Hello. I am a designer. I can design a logo for you. If you like it, I'll give it a gift.

Double quotes expand shell variables when used in some shells

First of all, thanks for making rnr!

I've spent a few minutes confused as to why the capture groups didn't work, only to realize later that I was using double quotes rather than single quotes, and so my shell (zsh in that case) was expanding them, thus rnr didn't receive anything.

A small example. Assuming we have the following list of files (songs encoded at a specific bitrate):

-128K Song1 .opus
-192K Song1 .opus
-128K Song2 .opus
-192K Song2 .opus

We want to rename the files to have the name of the song first, and the bitrate later:

Song1 128K.opus
Song1 192K.opus
Song2 128K.opus
Song2 192K.opus

We come up with a simple pattern: rnr "-(\d+K) (\w+) " "${2} ${1}" *. However this will not work: before rnr has the chance to read the arguments, ${2} will be substituted with the contents of the environment variable 2, and the same thing with happen for ${1}.

I don't think there's a technical solution here, however we can add a small warning in the capture groups part of the documentation. Maybe also in the "ARGS" part of the --help, just after " Expression replacement".

ripgrep has a paragraph about the same issue in the help text of the -r/--replace REPLACEMENT_TEXT flag:

In shells such as Bash and zsh, you should wrap the pattern in single quotes instead of double quotes. Otherwise, capture group indices will be replaced by expanded shell variables which will most likely be empty.

I can make a PR if you're okay with the idea.

Support change of case on case-insensitive file systems

On Windows, with a case-insensitive but case-preserving file-system, what's the best way to change the case of a file?

For example, this command produces an error message:

$ rnr -f .JPG$ .jpg image.JPG
Error: Conflict with existing path image.JPG -> image.jpg

Currently I'm renaming via a temp file name (eg, rename to .jpg.tmp, then strip out the .tmp). Maybe this would work if the conflict detection ignored the source file when checking to see if the target file exists, which is kind of an edge case due to case-insensitivity where the source file won't conflict once it has been renamed.

Silent mode

Implement silent mode to hide standard output of the application.

[Feature] Custom dump file base name

Hello! rnr is an excellent tool and I'm very grateful to you for making it!

When I run rnr a file like rnr-2024-08-09_101725.json is created in the current directory. This is nice (being able to undo my changes is great!) but a little bit annoying, because Git immediately shows an untracked file I have to be careful to not commit.

In my global gitignore file, I ignore all files that start with xxx so that I can write temporary notes and scratch output to files with names like xxx-notes.md or xxx-ghc-output.txt and not worry about committing them. I would like to instruct rnr to write its dump file with a name like this (e.g. xxx-rnr-2024-08-09_101725.json) to save me the hassle.

Does this make sense? I'm not sure when, but I could probably write an implementation if this sounds like a good idea to you.

[Feature] Configuration file

It would be nice to set some default options for rnr, like --backup, --force, --hidden, --recursive, --include-dirs, or --silent.

I would like a configuration file (e.g. ~/.config/rnr.toml) to set these options in.

This would require a few things:

  • Reading options from a configuration file as well as the command-line
  • Making sure that command-line options override the configuration file options
  • Adding negation options for some command-line options, so that (e.g.) if --silent is set in the configuration file, an option named something like --loud or --verbose can undo that setting at invocation-time

This is mostly a tracking issue, thanks again for rnr, it's super useful!

Issue with regex and capture groups

I am not sure if I'm doing something wrong here, but I'm trying to do this:

Statement_022024_1234.pdf->Statement_20240220_5678.pdf

But this command isn't doing what I expect:

rnr "_(\d\d)(\d\d)(\d\d)_1234" "_20${3}${2}${1}_5678" Statement_*

Instead, the dry run tells me that the command will do this:

Statement_022024_1234.pdf->Statement_20_5678.pdf

Is this a bug in rnr? I've just downloaded it, rnr 0.4.2

Support Unicode Normalization Forms

Unicode® Standard Annex #15
unicode-rs/unicode-normalization

NFC and NFD are particularly beneficial for macOS users. While APFS supports both NFC and NFD, many macOS APIs and applications automatically convert filenames to NFD. See: gist

NFKC and NFKD are useful for compatibility purposes. For example, it can convert Japanese squared characters like ㍿ and ㌀ to their compatible equivalents, such as 株式会社 and アパート. See: UAX #15: Examples of Compatibility Equivalence

Create examples

Create several examples explained in detail in the documentation.

--force option not working for to-ascii on Windows. Not renaming the files.

Hi all,

rnr --force --no-dump to-ascii "UDTEAL - 해상고속기동.mp3" 
This is a DRY-RUN
UDTEAL - 해상고속기동.mp3 -> UDTEAL - HaeSangGoSogGiDong.mp3

does not rename anything and leads to the same result as

rnr --dry-run --no-dump to-ascii "UDTEAL - 해상고속기동.mp3" 
This is a DRY-RUN
UDTEAL - 해상고속기동.mp3 -> UDTEAL - HaeSangGoSogGiDong.mp3

Tested on Windows 11 using releases v0.4.2, v0.4.1, and v0.4.0 with both msvc and gnu builds.

Other operations like
rnr --force -r foo bar .
are working just fine.

Kindly check and fix this bug.

Best regards

Possible to rename only directories and not files?

Hello, thanks for making this wonderful little tool!

I have a scenario where I have a bunch of directories, and each directory has files with same name as directory, but different extensions. Example -

├── X Men - Apocalypse (2016) (720p)
│   ├── X Men - Apocalypse (2016) (720p).mp4
│   └── X Men - Apocalypse (2016) (720p).srt
├── X Men - Days Of Future Past (2014) (720p)
│   ├── X Men - Days Of Future Past (2014) (720p).mp4
│   └── X Men - Days Of Future Past (2014) (720p).srt
├── X Men - First Class (2011) (720p)
│   ├── X Men - First Class (2011) (720p).mp4
│   └── X Men - First Class (2011) (720p).srt

I only want to rename the directories, but not the files inside. Is this possible with rnr? Going through the help page, it doesn't look like rnr supports this, but wanted to confirm.

[Feature request] Highlight replacements in dry-run mode.

Hi, thanks for rnr!

It would be nice to highlight in color what is replaced with what in a dry-run mode.

Useful cases:

  • files / directories with long names (surely human brain parses colors way faster than long symbol sequences, and then you also need to diff both paths!)
  • replacement occurs multiple times

That's how ripgrep highlights found matches by default, for instance (rg fn):

image

Or another toy example (echo barfoobar | rg bar --replace baz):
image

What do you think?

Regex replacement doesn't work in cmd.exe, only in sh.exe

Context (like in the other issue): About a year ago, Diesel changed the name format of the migrations that it generates. I still have many migrations in the old format and want to use rnr to rename them into the new format.

At first I tried to run this in cmd.exe:
rnr -D '(\d{4})(\d{2})(\d{2})(\d{6})' '$1-$2-$3-$4' ./* in my migrations folder, but it didn't show any matches/replacements, only This is a DRY-RUN.
I also tried with double quotes, but I got the same result (no matches/replacements) :/
(When I execute it in the sh.exe of the Git Shell (powershell) of GitHub Desktop for Windows, it works, but it's very inconvenient..)
Is there a way to make it work in cmd.exe, too?

Improve return code

Improve return code from different errors in the application to be properly handled by terminal/shells.

Interactive mode

Implement an interactive mode similar to git add --interactive, git add --patch, package managers, etc.

Windows support?

This tool seems very useful, does it support Windows, too? :)

Color mode

  • Make colored output configurable using a flag (--color): always, auto and never
  • Detect type of terminal/output for auto mode.

How to do `git mv` for renaming?

About a year ago, Diesel changed the name format of the migrations that it generates.
I still have many migrations in the old format and want to use rnr to rename them into the new format.
But how can I do the renaming with git mv so that git properly recognizes that the folders were renamed?
If I just do rnr -f -D '(\d{4})(\d{2})(\d{2})(\d{6})' '$1-$2-$3-$4' ./*, git shows the files as being removed and new files added.
When I use git mv manually, it correctly shows them as renamed..

regexp in windows

precondition:

  • windows 7 x86

Pattern "strin" should be changed to pattern "strout" in current directory
Does not work next command
rnr -n -r strin strout ./*
but the workaround with recursive option and dept=1 works well:
rnr -n -r -d 1 strin strout ./

next issue
regexp with single quotes does not work correct,
rnr -n -r -d 1 '(.+)\.d(\w+)' '${1}' ./
but double quotes works well
rnr -n -r -d 1 "(.+)\.d(\w+)" "${1}" ./

[Feature request] Add file names enumeration (counter) option

For example I have some files:
sadasd.png, asdjklsa,png, kflsadl.png
And I want to rename them to:
1.png, 2.png, 3.png
So as far as I know in current state it's impossible to do it?
P.S. Yeah, I know there are tons of tools that can do it but I'm interested in rnr only because it has working in cmd undo feature.

Multiple (different) renames possible in 1 pass?

Thank you for this amazing tool.

I am wondering if it's possible to achieve the following in a single pass of rnr:

.
├── dir1/
│   ├── file:with_a_*
│   └── file2_also_has<a_**-3
└── dir2/
    └── some!<other_file": ok?

I want to change [*<"?!] chars to underscores _ and change colon : to - (hyphen surrounded by space)

Final result should be:

.
├── dir1/
│   ├── file - with_a__
│   └── file2_also_has_a___-3
└── dir2/
    └── some__other_file_ -  ok?

Is it possible?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.