UNIX - Renaming files with long names - unix

I am screwed. I misused wildcards like a moron, in the rename command.
I repeated names twice in a 3gig folder, which I cannot afford to delete.
Now, the rename command is not working, and it says the file name is too long.
Please help me.
If programming can solve this, please let me know. I am a competent programmer in Java and PHP.

Under the hood, any rename command should get implemented with rename(). If you are in the directory where the file is and do:
mv hugefilenamethatiscreweduponandwanttobemuchshorted tersefile
it should work, as I don't think the path would get expanded out and overflow the limit. Otherwise, you can temporarily move the parent directory somewhere so it had a minimal path (like /p) and then rename the file and then move it back.

Related

Standardized filenames when passing folders between steps in pipeline architecture?

I am using AzureML pipelines, where the interface between pipeline steps is through a folder or file.
When I am passing data into the pipeline, I point directly to a single file. No problem at all. Very useful when passing in configuration files which all live in the same folder on my local computer.
However, when passing data between different steps of the pipeline, I can't provide the next step with a file path. All the steps get is a path to some folder that they can write to. Then that same path is passed to the next step.
The problem comes when the following step is then supposed to load something from the folder.
Which filename is it supposed to try to load?
Approaches I've considered:
Use a standardized filename for everything. Problem is that I want to be able to run the steps locally too, independant of any pipeline. This makes very for a very poor UX for that use case.
Check if the path is to a file, if it isn't, check all the files in the folder. If there is only one file, then use it. Otherwise throw an exception. This is maybe the most elegant solution from a UX perspective, but it sounds overengineered to me. We also don't structurally share any code between the steps at the moment, so either we will have repetition or we will need to find some way to share code, which is non-trivial.
Allow custom filenames to be passed in optionally, otherwise use a standard filename. This helpes with the UX, but often the filenames are supposed to be defined by the configuration files being passed in, so while we could do some bash scripting to get the filename into the command, it feels like a sub-par solution.
Ultimately it feels like none of the solutions I have come up with are any good.
It feels like we are making things more difficult for ourselves in the future if we assume some default filename. F.x. we work with multiple file types, so it would need to omit an extension.
But any way to do it without default filenames would also cause maintainence headache down the line, or incurr substantial upfront cost.
The question is am I missing something? Any potential traps, better solutions, etc. would be appreciated. It definately feels like I am somewhat under- and/or overthinking this.

Zsh: tab completion for files not in the current directory?

I'm new to zsh and I'm trying to figure out how to get tab completion to work so that when I typed part of the name of a file that's not in the current directory zsh will complete it.
The idea is that I have some scripts in ~ and c:\MyStuff\bin and I'd love for zsh to try and complete those (executable) scripts when I'm in other directories.
Being able to complete files that are anywhere in my path would be nice, but if it's easier to complete files using a list of directories set in my .zshrc, well, that would work fine too.
If anyone has any pointers for resources about how to do this, or even advice like "This will / won't work in zsh" that would be great. zsh seems open-ended enough that it ought to be able to do this AND ALSO I've searched long enough without finding anything that I wouldn't be surprised if there's nothing at the end of this rabbit hole :)
Thanks in advance!
So I decided to invest the time and actually try and read the (very, very thorough) zsh completion docs. There's a lot there, including a section which says that zsh actually does this out of the box:
8 Command Execution
"...the shell searches each element of $path for a directory containing an executable file by that name..."
Turns out this does work for me, it just takes a long time (more than a second or two) and so I thought it wasn't working.
Next up: looking at why it's taking so long - perhaps it's my very long $path variable :)

Ada `Gprbuild` Shorter File Names, Organized into Directories

Over the past few weeks I have been getting into Ada, for various different reasons. But there is no doubt that information regarding my personal reasons as to why I'm using Ada is out of scope for this question.
As of the other day I started using the gprbuild command that comes with the Windows version of GNAT, in order to get the benefits of a system for managing my applications in a project-related manner. That is, being able to define certain attributes on a per-project basis, rather than manually setting up the compile-phase myself.
Currently when naming my files, their names are based off of what seems to be a standard for the grpbuild, although I could very much be wrong. For periods (in the package structure), a - is put in the name of the file, for underscores, an _ is put accordingly. As such, a package by the name App.Test.File_Utils would have a file name of app-test-file_utils: .ads and .adb accordingly.
In the .gpr project file I have specified:
for Source_Dirs use ("app/src/**");
so that I am allowed to use multiple directories for storing my files, rather than needing to have them all in the same directory.
The Problem
The problem that arises, however, is that file names tend to get very long. As I am already putting the files in a directory based on the package name contained by the file, I was wondering if there is a way to somehow make the compiler understand that the package name can be retrieved from the file's directory name.
That is, rather than having to name the App.Test.File_Utils' file name app-test-file_utils, I would like it to reside under the app/test directory by the name file_utils.
Is this doable, or will I be stuck with the horrors of eventually having to name my files along the lines of: app-test-some-then-one-has-more_files-another_package-knew-test-more-important_package.ads? Granted, I have not missed something about how an Ada application should actually be structured.
What I have tried
I tried looking for answers in the package Naming configuration of the gpr files in the documentation, but to no avail. Furthermore I have been browsing the web for information, but decided it might be better to get help through Stackoverflow, so that other people who might struggle with this problem in the future (granted it is a problem in the first place) might also get help.
Any pointers in the right direction would be very helpful!
In the top-secret GNAT documentation there is a description of how to use non-default file names. It's a great deal of effort. You will probably give up, use the default names, and put them all in a single directory.
You can also simplify much of the effort by using GPS and letting it build your project file as you add files to your source directories.

Two identical CSS files, one modified, replace only the altered styles, is that possible?

I have two files where I edited one and left the other just for reference.
However I screwed some codes on the file I'm editing and since its a huge file, I don't know where I made the error or even if it have more errors. It was not altered I just deleted it.
I want to know if there is a program, plugin, script, something that I can insert the two files and override only the parameters of the classes that was edited (the class names wasn't altered).
I know I should have used GIT and all but I didn't. Lesson learned.
Appreciate any help. I'm using SublimeText.
If you're on a Unix-like OS, or you have Cygwyn installed you can use diff and patch to do this.
$ diff -u old.css new.css > changes.diff
$ patch < changes.diff

Protect.exe for AutoLISP code protection

I am developing an architectural LISP-based package for a member of the IntelliCAD consortium. Per recommendations I have found on websites, I have used the Kelvinator to deformat and disguise some of the code. Now I am attempting to use Protect.exe to encrypt the code. The exe seemed to work until I tried to put use a folder name in the output file name thus:
protect es.lsp L kelvinated\protected\es.lsp
First of all, can I do this? Will protect.exe work like this, or do the input and output file have to be in the same folder?
Also, one time I tried this and I got a "stack overflow" error. Therefore, I am here.
Kelvinator/protect et al are pretty old utilities, do you know the last time they were updated? Subtitle, they may expect old school 8.3 file / folder names.
As for "will this work?", I cannot say, as I use different schemes to protect my work when writing lisp for others (vlx/fas, bricscad's encryptor, my own loader / obfuscators ...).
A stack overflow in this context suggests a recursion error, perhaps when it tries to reconcile the pathing you're providing.
Have you tried to use the DOS short path? Putting the path in quotes? Using forward slashes? Using double backslashes?
What happens if you pass "/?" (and alternates) on the command line, does it provide any help?
Finally, if it refuses to process the files unless they share they same directory you could always front end with with a batch file that does the housekeeping for you.
Michael.

Resources