Rename question

Hello,

currently I have the following rename scripts






How can I combine them to one script?

Regards
xbprm

It appears you're trying to replace underbars with spaces, and remove the final _stuff component?

It would be better to show the input variations (i.e. possible file names), and ask how to accomplish the task, rather than show several REs.

I have files consisting of character groups separated by "_" and at the end a group of numbers.

These files I want to sort into folders consisting of the character groups and the "_" replaced by spaces.








Hope that makes it clearer.

Sometimes it is just easier to break the problem into parts. Use a script (attached) to do the two basic replacements. It looks like this:

[code]@script jscript

function Rename::GetNewName2 ( strFileName, strFilePath, fIsFolder, strOldName, strNewName )
{
name=strNewName.replace(/
\d+./,".");
name=name.replace(/_/g," ");

return name;
}[/code]
strip digits undscr to space.zip (462 Bytes)

Seems, I wasn't clear enough :wink:

The file name has a variable number of character groups connected by "_" and a number group at the end.

  1. This file name shall be converted into a folder name by replacing "" and removing the number group together with its preceding "" and the extension is also removed for the folder name.
  2. The rename then uses the folder name as place to move the unrenamed] file to.

Problem is that I don't want to manually select files based on the number of character groups but the rename shall do this on its own.

Try replacing the script code with this:

[code]@script jscript

function Rename::GetNewName2 ( strFileName, strFilePath, fIsFolder, strOldName, strNewName )
{
folder=strNewName.replace(/
\d+..*/,"");
folder=folder.replace(/_/g," ");

return '..\' + folder + '\' + strFileName;
}[/code]