Skip to content
Advertisement

Using regular expression search and replace rename on linux with directory creation

Take a list of files such as:

JavaScript

I would like to rename these files and add some formatting similar to this:

JavaScript

This would end up with the list of files looking like

JavaScript

Up to here, this all works fine. The next step, and my real question is, how can I create a directory for each SubGroup in this process using the SubGroup name for the directory?

For example, my first guess was to do something like this

JavaScript

The intent of this would be to rename the files to look something like this

JavaScript

However, I end up with a message like

JavaScript

It seems the problem is that the directory Group01SubGroup01 needs to already exist for this to complete successfully. Any ideas on how I can somehow use regular expression search and replace syntax to create directories if they don’t already exist?

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement