Simple C/C++ runcible script to uppercase file names
Tags cimple c, computer mad science, runc
Runcible. Runc-able. Same thing... ;-)
As we feared, runc is getting out of control.. Atomic ants, vivisection, computer mad science... you just never know what might happen.
But...
Today's Features
[The latest runc compiles and runs in the user's HOME folder in a private '.runc' directory... see link at the bottom for more.]
file: mv-upper
purpose: utility (executable)
To run the above code in a windows partition type 'runc <filename>' because we can't set the file itself to be executable in windows.
Requires only gcc/g++ (standard stuff) and runc-rs (a computer mad science experiment that appears to have some merit).
Like I said. You just never know... ;-)
You can take runc for a spin here.
"Run C/C++ Code As Script"
http://www.linuxquestions.org/questi...-script-35691/
dload, compile, install, uninstall. It all works. Also has a deb package builder if you prefer that kind of thing. (GPL v. 3.0+)
The Computer Mad Science Team
:-)
As we feared, runc is getting out of control.. Atomic ants, vivisection, computer mad science... you just never know what might happen.
But...
Today's Features
- More great stuff for C/C++ beginners.
- Example of using C/C++ code to change file names to upper case.
- How to run runc on a script/source code in a filesystem you can't make it executable in.
[The latest runc compiles and runs in the user's HOME folder in a private '.runc' directory... see link at the bottom for more.]
file: mv-upper
purpose: utility (executable)
Code:
#!/usr/local/bin/runc // This is a runc C/C++ shell program to change the names of all the files // in the current directory to uppercase names. In this case, I was working // in a windows partition and we can't set the executable flags on this // source file, but the program runs as 'runc <sourcename>' even in a // windows partition. // To make this a generic app to change file names to uppercase (spaces in names // are ok), add code to allow a quoted flespec for the files to convert. Note: // If there is mysteriously more than one file in the args list, the shell probably // expanded wildcards, so it's best to quote the filespec. #include <string.h> // strcpy() #include <stdlib.h> // system() #include <ctype.h> // char type stuff like toupper() #include <runc.h> int err; void cvt_upper(char* newname); int main(int argc, char** argv) { char** list = slist_new(); char newname[256]; char* oldname; // I wanted to change the names of all my ASY files to upper case so they // would be easier to read in the file selection tool in ltspice (running in // linux with wine). slist_pipeRead(&list, "ls *.asy 2>/dev/null"); for(int i = 0; i < slist_count(&list); i++) { oldname = slist_get(&list, i); strcpy(newname, oldname); cvt_upper(newname); // we can't 'mv' directly to the new name so we change its name twice. err = system(tmpstr(256, "mv %s tmpfile && mv tmpfile '%s'", oldname, newname)); } return 0; } void cvt_upper(char* newname) { char* p = newname; while(*p) *p++ = toupper(*p); }
Requires only gcc/g++ (standard stuff) and runc-rs (a computer mad science experiment that appears to have some merit).
Like I said. You just never know... ;-)
You can take runc for a spin here.
"Run C/C++ Code As Script"
http://www.linuxquestions.org/questi...-script-35691/
dload, compile, install, uninstall. It all works. Also has a deb package builder if you prefer that kind of thing. (GPL v. 3.0+)
The Computer Mad Science Team
:-)
Total Comments 0