Renaming randomly numbered, but matching files

Javascript renaming examples. Javascript renaming is supported in version 3 or newer.

Renaming randomly numbered, but matching files

Postby Drift_91 » Mon Feb 06, 2023 3:34 am

Sorry for the indescriptive title, but I couldn't come up with anything in such a short space.

I'm trying to rename thousands of model files that are numbered inconsecutively, and in multiple groups, to be in a single consecutive numbering order. To further complicate things, each model has one or more texture files that need to be renamed to match. I'm fairly certain the only solution in BRU is Javascript, but I have almost no experience with Javascript and I don't see any variables in the help file that I could use the check if a number already exists. Also I have no idea how one would separate different parts of the filename with Regex to work with them separately.

Here's an example:
Code: Select all
//models:
mp_f_freemode_01^accs_003_u.ydd -> mp_f_freemode_01_mp_f_clothes_01^accs_000_u.ydd
mp_f_freemode_01^accs_004_u.ydd -> mp_f_freemode_01_mp_f_clothes_01^accs_001_u.ydd
mp_f_freemode_01^accs_013_u.ydd -> mp_f_freemode_01_mp_f_clothes_01^accs_002_u.ydd
mp_f_freemode_01_female_freemode_business^accs_004_u.ydd -> mp_f_freemode_01_mp_f_clothes_01^accs_003_u.ydd

//textures:
mp_f_freemode_01^accs_diff_003_a_uni.ytd -> mp_f_freemode_01_mp_f_clothes_01^accs_diff_000_a_uni.ytd
mp_f_freemode_01^accs_diff_003_b_uni.ytd -> mp_f_freemode_01_mp_f_clothes_01^accs_diff_000_b_uni.ytd
mp_f_freemode_01^accs_diff_003_c_uni.ytd -> mp_f_freemode_01_mp_f_clothes_01^accs_diff_000_c_uni.ytd
mp_f_freemode_01^accs_diff_004_a_uni.ytd -> mp_f_freemode_01_mp_f_clothes_01^accs_diff_001_a_uni.ytd
mp_f_freemode_01^accs_diff_004_b_uni.ytd -> mp_f_freemode_01_mp_f_clothes_01^accs_diff_001_b_uni.ytd
mp_f_freemode_01^accs_diff_004_c_uni.ytd -> mp_f_freemode_01_mp_f_clothes_01^accs_diff_001_c_uni.ytd
mp_f_freemode_01^accs_diff_013_a_uni.ytd -> mp_f_freemode_01_mp_f_clothes_01^accs_diff_002_a_uni.ytd
mp_f_freemode_01^accs_diff_013_b_uni.ytd -> mp_f_freemode_01_mp_f_clothes_01^accs_diff_002_b_uni.ytd
mp_f_freemode_01_female_freemode_business^accs_diff_004_a_uni.ytd -> mp_f_freemode_01_mp_f_clothes_01^accs_diff_003_a_uni.ytd
mp_f_freemode_01_female_freemode_business^accs_diff_004_b_uni.ytd -> mp_f_freemode_01_mp_f_clothes_01^accs_diff_003_b_uni.ytd
mp_f_freemode_01_female_freemode_business^accs_diff_004_c_uni.ytd -> mp_f_freemode_01_mp_f_clothes_01^accs_diff_003_c_uni.ytd
mp_f_freemode_01_female_freemode_business^accs_diff_004_d_uni.ytd -> mp_f_freemode_01_mp_f_clothes_01^accs_diff_003_d_uni.ytd
Drift_91
 
Posts: 1
Joined: Mon Feb 06, 2023 2:59 am

Re: Renaming randomly numbered, but matching files

Postby Admin » Fri Feb 24, 2023 7:30 am

Yes, it should be possible to do in Javascript in BRU, but what is the "logic" / algorithm to be implemented ?
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm


Return to Javascript Renaming


cron