Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to change the case of a pattern? #17

Closed
tandrewnichols opened this issue Feb 22, 2016 · 9 comments
Closed

Is there a way to change the case of a pattern? #17

tandrewnichols opened this issue Feb 22, 2016 · 9 comments

Comments

@tandrewnichols
Copy link

E.g. I would like to convert "FooBar.txt" to "foobar.txt" on many files.

@75lb
Copy link
Owner

75lb commented Feb 22, 2016

which OS are you on, i assume you're on a case-insensitive OS (Mac or Windows)?

@tandrewnichols
Copy link
Author

OSX Yosemite. Yeah, it's case-insensitive, but that actually doesn't matter in this case. Context:

I'm using grunt spritesmith to generate a spritesheet of a bunch of images, and it uses the filenames to generate CSS classes, and it preserves the casing of the filenames.

@75lb
Copy link
Owner

75lb commented Feb 22, 2016

this boils down to case-insensitivity at the OS level.. node essentially considers these two files the same, thus renamer doesn't think there's any work to do..

> fs.existsSync('file2.test')
true
> fs.existsSync('File2.test')
true

i'm flippin starving now but will fix it later!

@tandrewnichols
Copy link
Author

I was able to do it with pure bash, though it wasn't easy because of the filesystem case-insensitivity. It kept thinking I was moving a file to the exact same name and wouldn't let me, so I had to move them to a temp directory as I lower cased them, and then move them back. Anyway, the point is, it's not urgent for me. I have the files now in the form I need them. But something like --transform lowercase could be a nice addition to the tool. It seems like, regardless of the file system, you could, in that case, call String.toLowerCase on the filename before writing it no matter what.

@kilianc
Copy link

kilianc commented May 20, 2016

I always keep my project files in a case sensitive partition, this would be pretty handy to have +1

@wellguimaraes
Copy link

wellguimaraes commented Jul 22, 2016

I thought that a solution could be a "pre defined function" argument (--fn/-s) to identify a function (maybe from string.js -- humanize, camelize, dasherize, etc) to receive the fileName after replacements. It could solve this and be a useful feature. What do you think?

@75lb
Copy link
Owner

75lb commented Jul 22, 2016

@wellguimaraes yeah, would be useful to have the option to pass in a custom transform function if the built-in case-insensitive rename didn't cover your needs.. that will likely go in the next version.

@75lb
Copy link
Owner

75lb commented Jun 17, 2018

It's now possible to change a file's case in renamer v1.0.0 (prerelease available here).

On case-insensitive systems, this command (renaming FILE.jpg to file.jpg) will fail as the target file already exists.

$ renamer --replace file.jpg FILE.jpg

In renamer v1, you can override this by passing --force.

$ renamer --replace file.jpg FILE.jpg --force

Version 1 is still in prerelease so feedback welcome at this stage!

@75lb
Copy link
Owner

75lb commented Jul 17, 2018

fixed and released in renamer v1.0.0.

@wellguimaraes , there's a new plugin to achieve what you suggested here.

@75lb 75lb closed this as completed Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants