Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

rer - regex file renamer

regex rename c

  • Please log in to reply
2 replies to this topic

#1 serpent

serpent

    CC Regular

  • Member
  • PipPipPip
  • 30 posts
  • Programming Language:C++, PHP

Posted 29 October 2014 - 02:03 PM

rer - regular expression based file renamer

rer /pattern/replacement/modifiers file [file [...]]

Each given file is matched against pattern; if match is found the file is renamed.

 

Language: C

Tested system: FreeBSD 9.3

Requirements (build): bmake, pcre

License: 2-clause BSD

 

Examples:
rename all IMG* files to picture* (e.g. IMG_1000.jpg to picture_1000.jpg)

rer /IMG/picture/ IMG*

Swap first word with second (renaming foo-bar to bar-foo, foo-123 to 123-foo)

rer '/(\w+)-(\w+)/\2-\1/' foo-bar foo-123

It runs fine on my FreeBSD system, but it's very early stage and I'm not sure it will compile on Linux - bmake is used to build project.

I've pushed code to github:
https://github.com/serpent7776/rer

Hope it will be usefull.


  • 0

#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts
  • Location:Argentina
  • Programming Language:C, C++, C#, PHP, JavaScript, Transact-SQL, Bash, Others
  • Learning:Java, Others

Posted 29 October 2014 - 10:59 PM

Nice work! What would be the ultimate use of this app?

I've done a silly tutorial about regex and renaming files for cleaning up downloaded file names: Downloaded files manager

 

So I am guessing your idea might have a similar application. Oh I think it's in windows and Mac where it would be the most useful, since in Linux you can do that with sed, shell script, awk, etc.


  • 0

#3 serpent

serpent

    CC Regular

  • Member
  • PipPipPip
  • 30 posts
  • Programming Language:C++, PHP

Posted 30 October 2014 - 11:33 AM

My goal is to create tool to rename files implemented in C with as few external dependencies as possible. For now it's minimal working version and only supports regex renaming, but I'm going to add a few more options.

My application could be used in a way similar to your Downloaded files manager, but rer is console application, not a GUI. I don't target windows and Mac platforms - I don't use these systems; besides typical windows user do not use console applications.

Indeed *NIX user can use sed/awk/shell, but using rer is simplier :)


  • 0





Also tagged with one or more of these keywords: regex, rename, c

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download