Coder Social home page Coder Social logo

rename's People

Contributors

ap avatar mattpr 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rename's Issues

-N flag rejects patterns that don't start with 0

Macos Mojave, version 1.601, installed via homebrew.

$ rename -n -N 10 's/.*/V1D2E$N.mkv/' *.mkv
Error: unparseable counter format 10

vs

$ rename -n -N 010 's/.*/V1D2E$N.mkv/' *.mkv
'title_t00.mkv' would be renamed to 'V1D2E010.mkv'
'title_t01.mkv' would be renamed to 'V1D2E011.mkv'
'title_t02.mkv' would be renamed to 'V1D2E012.mkv'
'title_t03.mkv' would be renamed to 'V1D2E013.mkv'
'title_t04.mkv' would be renamed to 'V1D2E014.mkv'
'title_t05.mkv' would be renamed to 'V1D2E015.mkv'
'title_t06.mkv' would be renamed to 'V1D2E016.mkv'
'title_t07.mkv' would be renamed to 'V1D2E017.mkv'
'title_t08.mkv' would be renamed to 'V1D2E018.mkv'

Man page says:

$N A counter that increments for each file in the list. By default, counts up from 1.

The "-N" switch takes a template that specifies the padding and starting value of $N; see "Switches".

Expected behaviour:

Providing a parameter like 10 implies the starting value of $N should be 10 and there should be no zero padding.

--noctrl option tries to replace unicode right single quotation mark

Let's say I have a file called bob’s.txt. I run prename on it and get:

• prename -n --noctrl bob’s.txt
'bob’s.txt' would be renamed to 'bob�_s.txt'

Actually running the command would result in the file being named 62 6f 62 E2 5F 73 2E 74 78 74, which is invalid UTF-8 because of the E2 byte. I don't think this should happen.

Bareword found where operator expected

$ brew info rename
rename: stable 1.600 (bottled), HEAD
Perl-powered file rename script with many helpful built-ins
http://plasmasturm.org/code/rename
Conflicts with:
  util-linux (because both install `rename` binaries)
/usr/local/Cellar/rename/1.600_1 (4 files, 41.9KB) *
  Poured from bottle on 2018-09-10 at 16:13:29
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/rename.rb
==> Options
--HEAD
	Install HEAD version
==> Analytics
$ rename -- '_%28Civ5%29' '' *
install: 3,789 (30 days), 13,064 (90 days), 47,263 (365 days)
install_on_request: 3,472 (30 days), 11,602 (90 days), 43,035 (365 days)
build_error: 0 (30 days)
Bareword found where operator expected at (eval 2) line 1, near "28Civ5"
	(Missing operator before Civ5?)
Bareword "_" not allowed while "strict subs" in use at (eval 2) line 1.
syntax error at (eval 2) line 1, near "28Civ5"

Bug with Corner cases in renaming impossible file names

(continued from #8)

  • I'm writing a small (fix-file-names.sh), that's how I end up with all these edge cases. I even managed to find this (I think) small bug related to as close to the edge you can get an edge case (rename gave up) :

Screenshot of Finder (04-12-2019, 07-20-33)

Screenshot of iTerm2 (04-12-2019, 07-20-15)

Of course, it's playing dirty serving rename a diet of filenames that only consists of the most impossible-to-handle characters: '$' and '/' and '*' and such... but it's apparently perfectly valid file names in Finder. I work as a consultant working exclusively with networked macOS and iOS boxes around town, and nothing shocks me anymore - if it can be typed, it will end up in a file or folder name sooner or later. And, somewhere along the way, backblaze, rsync, time machine, xar or ditto or even more probably: one of my shell glue scripts, one of those are going to get thrown way off balance by that ' / ' or ' /" ' ...

Don't know if its worth spending the time to band-aid these incredible corner cases, but now at least you are aware of a few perfect 90.000 degree corner cases.

Perhaps you have to go the route of identifying the inode of the file/folder and calling dd(1) [sp?] to zero-out the corresponding parts in the directory?

Anyways.. thanks for a great utility! It's hard at work over here in Oslo, Norway.

//haakon

`-c` not working on case-insensitive systems like macOS

Command-line says more than words:

$ touch UPPERCASE
$ rename -c UPPERCASE
'UPPERCASE' not renamed: 'uppercase' already exists

This was on macOS 12.3.1 on a case-insensitive APFS filesystem.

It would be great if the lower case renaming would work natively. Currently I have to make a wrapper in my renaming script for macOS to rename to a temporary file.

A workaround currently exist by forcing an overwrite

$ rename -c -f UPPERCASE

utf-8 stuff

The output of prename -h is

Usage:
    rename [switches|transforms] [files]

    Switches:

    -0/--null (when reading from STDIN)
    -f/--force or -i/--interactive (proceed or prompt when overwriting)
Wide character in print at /usr/share/perl5/core_perl/Pod/Text.pm line 303.
    -g/--glob (expand "*" etc. in filenames, useful in Windows™ CMD.EXE)
    -k/--backwards/--reverse-order
    -l/--symlink or -L/--hardlink
    -M/--use=Module
    -n/--just-print/--dry-run
    -N/--counter-format
    -p/--mkpath/--make-dirs
    --stdin/--no-stdin
    -t/--sort-time
    -T/--transcode=encoding
    -v/--verbose

    Transforms, applied sequentially:

    -a/--append=str
    -A/--prepend=str
    -c/--lower-case
    -C/--upper-case
    -d/--delete=str
    -D/--delete-all=str
    -e/--expr=code
    -P/--pipe=cmd
    -s/--subst from to
    -S/--subst-all from to
    -x/--remove-extension
    -X/--keep-extension
    -z/--sanitize
    --camelcase --urlesc --nows --rews --noctrl --nometa --trim (see manual)

Is there a way to fix the Wide character in print at /usr/share/perl5/core_perl/Pod/Text.pm line 303? I assume it's related to the (tm) that is printed.

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.