Running AR from a .bat file

Advanced Renamer forum
#1 : 08/03-19 21:26
J
J
Posts: 4
Hi there - I have a regex setup to add the folder name to the files it contains, unless the files already start with the folder name. I have saved it as a preset in AR.

Can I create a batch file to run the preset on the nominated folder and subfolders? Can't find anything on this, and sorry if that's just because I don't really know what terms to search!

Regards,
J


08/03-19 21:26
#2 : 08/03-19 21:43
David Lee
David Lee
Posts: 1125
Have a look at www.advancedrenamer.com/user_guide/commandline

Also - "Command line configuration..." on the "Program" menu.

I've not yet tried to use this feature so I would appreciate it if you would let us know how you get on.




08/03-19 21:43
#3 : 08/03-19 22:02
J
J
Posts: 4
Reply to #2:
It's amazing! I have a problem, though, as it's adding the foldername even if the filename already contains it. Seems to be ignoring the regex somehow...


08/03-19 22:02
#4 : 09/03-19 10:11
David Lee
David Lee
Posts: 1125
Reply to #3:
I've just given this a try and it works perfectly from a batch file.

Assuming a hyphen as a separator between folder name and filename, I used the Replace method using a Regular Expression...
...replace: ^(<DirName:1>-)?
...with: <DirName:1>-

If "Case sensitive" is ticked and there is a difference in capitalization between the folder name and the filename prefix then the duplication you see would occur - could this be your problem?


09/03-19 10:11
#5 : 10/03-19 00:51
J
J
Posts: 4
Reply to #4:
Thanks David! Where is 'case sensitive' an option? I don't see it in the command line configuration tool.


10/03-19 00:51
#6 : 10/03-19 00:53
J
J
Posts: 4
Reply to #4:
This is my regex:
^\s*(?!(?:[\w\-\']+\s*){1,5},\s(?:[\w\-\']+\.?\s*){1,5}-\s*)(.*)$

It works perfectly in the manual program, but when I use the same settings in the batch file, it adds the directory name to every file, even when that's already been done (in the manual running of the program, it does not).

Thanks for any help!


10/03-19 00:53 - edited 10/03-19 01:04
#7 : 11/03-19 15:14
David Lee
David Lee
Posts: 1125
Reply to #6:
I assume that this RegEx is supposed to load only filenames not commencing with the folder name. However even in ARen GUI it loads ALL files in each folder when I try it.

Why are you trying to be so clever? The solution I gave you in Reply #4 is much simpler:

In the GUI:
Load ALL your files into the list - Add the top-level directory you are interested in and select "Include subfolders". Leave the mask and RegEX fields blank.

Now use the Replace method using a Regular Expression, as I suggested previously:
...replace: ^(<DirName:1>)?
...with: <DirName:1>

Save as a Method list file (.aren) and use this in the Command line configuration utility.
Select Items from path, enter your top-level directory and select "Also add items from subfolders", leaving the mask and RegEX fields blank as in the GUI version.

Once you have it working you can edit the command to accept the folder path as a variable in the batch file - but that is a Windows problem.



11/03-19 15:14