Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Blogs > rainbowsally
User Name


Rate this Entry

Simple C/C++ runcible script to uppercase file names

Posted 09-10-2013 at 06:13 AM by rainbowsally
Updated 09-10-2013 at 06:16 AM by rainbowsally

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.


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)

// 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);
    // 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;
    *p++ = toupper(*p);
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"

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
Posted in Uncategorized
Views 861 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 11:50 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration