JREN.BAT v2.8 - Rename files/folders using regular expressions

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
kurokirasama
Posts: 3
Joined: 19 Sep 2017 18:03

Re: JREN.BAT - Rename files/folders using regular expressions

#31 Post by kurokirasama » 23 Oct 2017 19:42

Hello,

is there a way to remove japanese characters from filenames using jren?

Regards,

dbenham
Expert
Posts: 2243
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: JREN.BAT - Rename files/folders using regular expressions

#32 Post by dbenham » 24 Oct 2017 11:02

This should be possible, but I haven't tested.

JREN works internally using JSCRIPT, which in turn uses Unicode. So you simply need to know the various Unicode code point ranges that correspond to Japanese characters, and then transform that into a regex square bracket character set expression. I'm pretty sure this list is incomplete, but it should get you started:

Code: Select all

jren "[\u4E00-\u9FbF\u3040-\u309F\u30A0-\u30FF]" ""


Perhaps you could simply remove all characters that are not ASCII, which would be much simpler to specify

Code: Select all

jren "[^\u0000-\u007F]" ""
or

Code: Select all

jren "[^\x00-\x7F]" ""


Of course, nothing will work if the names consist of only Japanese characters, or it you end up with duplicate names when you remove the Japanese characters.


Dave Benham

kurokirasama
Posts: 3
Joined: 19 Sep 2017 18:03

Re: JREN.BAT - Rename files/folders using regular expressions

#33 Post by kurokirasama » 24 Oct 2017 12:37

Thanks a lot. Is there any difference between the last 2 command?

dbenham
Expert
Posts: 2243
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: JREN.BAT - Rename files/folders using regular expressions

#34 Post by dbenham » 24 Oct 2017 12:49

The end result of the last 2 commands should be the same.

kurokirasama
Posts: 3
Joined: 19 Sep 2017 18:03

Re: JREN.BAT - Rename files/folders using regular expressions

#35 Post by kurokirasama » 20 Dec 2017 06:16

Hello again,

I have videos files with filenames:

Code: Select all

Series.Name.S01E01.andalotofstuff.mkv
Series.Name.S01E02.andalotofstuff.mkv
Series.Name.S02E01.andalotofstuff.mkv
etc
.

where "andalotofstuff" is not necessarily the same in each file, and can include ".", "-", "[" and "]".

I also have subtitles files with filenames:

Code: Select all

Series Name 1x01 - Episode Name andotherstuff.srt
Series Name 1x02 - Episode Name andotherstuff.srt
Series Name 2x01 - Episode Name andotherstuff.srt
etc.
where "andotherstuff" is not necessarily the same in each file, and can include "(" and ")".

What i want is to rename "srt" files with the corresponding "mkv".

Some real examples are:

Code: Select all

Marvels.Agents.of.S.H.I.E.L.D.S05E04.720p.HDTV.x264-AVS[eztv].mkv
Marvel's Agents of S.H.I.E.L.D. 5x04 - A Life Earned (Español (Latinoamérica)).srt
  
The.Shannara.Chronicles.S02E08.720p.HDTV.x264-AVS[eztv].mkv
The Shannara Chronicles 2x08 - Amberle (Español (España)).srt
    
The.Shannara.Chronicles.S02E10.720p.HDTV.x264-KILLERS[eztv].mkv
The Shannara Chronicles 2x10 - Blood (English).srt
Note that not necessarily all video files has a corresponding subtitle file.

So, is there a way to do this with JREN? It doesn't mater if the solution has many steps.

zorro101
Posts: 6
Joined: 17 May 2018 05:48

Re: JREN.BAT - Rename files/folders using regular expressions

#36 Post by zorro101 » 17 May 2018 05:52

hi
i have 3000 file like this:
20170419171730.m2ts
20170419171730.m2ts.modd
20170419171730.m2ts.moff

i need to rename 2017* to 2018*
there is a way?

thanks
best regards
zorro

Squashman
Expert
Posts: 4106
Joined: 23 Dec 2011 13:59

Re: JREN.BAT - Rename files/folders using regular expressions

#37 Post by Squashman » 17 May 2018 07:26

zorro101 wrote:
17 May 2018 05:52
hi
i have 3000 file like this:
20170419171730.m2ts
20170419171730.m2ts.modd
20170419171730.m2ts.moff

i need to rename 2017* to 2018*
there is a way?

thanks
best regards
zorro
You could certainly do this with JREN but it is easy enough to do with a normal batch file. Just create a substring of the file name to remove the first 4 characters.

Aacini
Expert
Posts: 1598
Joined: 06 Dec 2011 22:15
Location: México City, México

Re: JREN.BAT - Rename files/folders using regular expressions

#38 Post by Aacini » 17 May 2018 08:44

A simple REN command works here:

Code: Select all

C:\Users\Antonio\Documents\ASMB\Test
>dir /B
20170419171730.m2ts
20170419171730.m2ts.modd
20170419171730.m2ts.moff

C:\Users\Antonio\Documents\ASMB\Test
>ren 2017* 2018*

C:\Users\Antonio\Documents\ASMB\Test
>dir /B
20180419171730.m2ts
20180419171730.m2ts.modd
20180419171730.m2ts.moff
Antonio

Squashman
Expert
Posts: 4106
Joined: 23 Dec 2011 13:59

Re: JREN.BAT - Rename files/folders using regular expressions

#39 Post by Squashman » 17 May 2018 09:19

Aacini wrote:
17 May 2018 08:44
A simple REN command works here:
I always forget the RENAME command can do that. I have broken my golden rule of K.I.S.S.!

zorro101
Posts: 6
Joined: 17 May 2018 05:48

Re: JREN.BAT - Rename files/folders using regular expressions

#40 Post by zorro101 » 18 May 2018 00:28

sorry, but ren not work for me
I had already tried, but convert only the single extension files (.m2ts)
all other file are ignored (invisible - if i make dir the double extension file not show)
i used windows 7 pc

please can you help me?
thanks
best regards


Aacini
Expert
Posts: 1598
Joined: 06 Dec 2011 22:15
Location: México City, México

Re: JREN.BAT - Rename files/folders using regular expressions

#42 Post by Aacini » 22 May 2018 07:18

Did you saw my reply above? It is an example of the files and the command I used, copied directly from the screen. Such an example proves that my REN command correctly works, at least on my computer...

I suggest you to do exactly the same: create a few files, use the same REN command I used and then copy the screen contents and post it here (surrounded by [ code ] tags). Otherwise we have not idea of what are the files nor the command you used... :(

Antonio

zorro101
Posts: 6
Joined: 17 May 2018 05:48

Re: JREN.BAT - Rename files/folders using regular expressions

#43 Post by zorro101 » 22 May 2018 08:40

thanks for reply

I managed to do only the printscreen
ren.jpg
ren.jpg (89.77 KiB) Viewed 2404 times
thanks again


sst
Posts: 71
Joined: 12 Apr 2018 23:45

Re: JREN.BAT - Rename files/folders using regular expressions

#45 Post by sst » 06 Jun 2018 04:41

@zorro101
Your .modd and .moff files have hidden or system attributes set. Most probably only hidden attribute as it seems from your screenshot.

Code: Select all

attrib -h *.m2ts.*
ren 2017* 2018*
If you want to restore the attributes after the rename operation, then before running the above code, first run

Code: Select all

attrib *.m2ts.*
and take a note of the attributes, then after you've done with rename, do one of the following as appropriate

Code: Select all

attrib +h *.m2ts.*
attrib +s *.m2ts.*
attrib +h +s *.m2ts.*
you can use /S switch with attrib to apply the attributes to all matching files in the current folder as well as subfolders in one shot, like:

Code: Select all

attrib -h -s *.m2ts.* /S

Post Reply