#1 : 31/01-19 20:17 Matt Rascon
Posts: 1
|
I have a set of albums in which the title for each track is repeated three times in the filename. I want to rename these files (about 100) with the title given only once.
EXAMPLE: Killing FieldKilling FieldKilling Field --> Killing Field Baby BabyBaby BabyBaby Baby --> Baby Baby Is this possible to do in a batch? |
#2 : 31/01-19 22:58 David Lee
Posts: 1125
|
Reply to #1:
If your examples represent the entire filenames then you could use this script: name = item.name; return name.slice(0, name.length/3); |
#3 : 15/02-19 11:46 _H_
Posts: 8
|
Reply to #1:
https://i.imgur.com/ljvq68E.png |
#4 : 15/02-19 13:14 David Lee
Posts: 1125
|
Reply to #3:
Your RegEx leaves TWO spaces between the component words of the filename. You need to match the leading space in BOTH sub patterns: (\h\w+)(\1) A simpler regular expression would be: \w+ \w+ which matches two "words" each beginning with a space (note there is a space before each "\w") However, either of these solutions assume that the filenames always comprise the repetition of exactly two words separated by a space. Otherwise the script to extract just the first third of the original filename will be more general. |